Lines Matching refs:Inst

49     Instruction *Inst;
51 SimpleValue(Instruction *I) : Inst(I) {
52 assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
56 return Inst == DenseMapInfo<Instruction*>::getEmptyKey() ||
57 Inst == DenseMapInfo<Instruction*>::getTombstoneKey();
60 static bool canHandle(Instruction *Inst) {
62 if (CallInst *CI = dyn_cast<CallInst>(Inst))
64 return isa<CastInst>(Inst) || isa<BinaryOperator>(Inst) ||
65 isa<GetElementPtrInst>(Inst) || isa<CmpInst>(Inst) ||
66 isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
67 isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
68 isa<ExtractValueInst>(Inst) || isa<InsertValueInst>(Inst);
92 Instruction *Inst = Val.Inst;
96 for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
97 Res ^= getHash(Inst->getOperand(i)) << (i & 0xF);
99 if (CastInst *CI = dyn_cast<CastInst>(Inst))
101 else if (CmpInst *CI = dyn_cast<CmpInst>(Inst))
103 else if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(Inst)) {
107 } else if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(Inst)) {
113 assert((isa<CallInst>(Inst) ||
114 isa<BinaryOperator>(Inst) || isa<GetElementPtrInst>(Inst) ||
115 isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
116 isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst)) &&
121 return (Res << 1) ^ Inst->getOpcode();
125 Instruction *LHSI = LHS.Inst, *RHSI = RHS.Inst;
142 Instruction *Inst;
144 CallValue(Instruction *I) : Inst(I) {
145 assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
149 return Inst == DenseMapInfo<Instruction*>::getEmptyKey() ||
150 Inst == DenseMapInfo<Instruction*>::getTombstoneKey();
153 static bool canHandle(Instruction *Inst) {
155 if (Inst->getType()->isVoidTy())
158 CallInst *CI = dyn_cast<CallInst>(Inst);
184 Instruction *Inst = Val.Inst;
187 for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i) {
188 assert(!Inst->getOperand(i)->getType()->isMetadataTy() &&
190 Res ^= getHash(Inst->getOperand(i)) << (i & 0xF);
194 return (Res << 1) ^ Inst->getOpcode();
198 Instruction *LHSI = LHS.Inst, *RHSI = RHS.Inst;
374 Instruction *Inst = I++;
377 if (isInstructionTriviallyDead(Inst)) {
378 DEBUG(dbgs() << "EarlyCSE DCE: " << *Inst << '\n');
379 Inst->eraseFromParent();
387 if (Value *V = SimplifyInstruction(Inst, TD, TLI, DT)) {
388 DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n');
389 Inst->replaceAllUsesWith(V);
390 Inst->eraseFromParent();
397 if (SimpleValue::canHandle(Inst)) {
399 if (Value *V = AvailableValues->lookup(Inst)) {
400 DEBUG(dbgs() << "EarlyCSE CSE: " << *Inst << " to: " << *V << '\n');
401 Inst->replaceAllUsesWith(V);
402 Inst->eraseFromParent();
409 AvailableValues->insert(Inst, Inst);
414 if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
424 AvailableLoads->lookup(Inst->getOperand(0));
426 DEBUG(dbgs() << "EarlyCSE CSE LOAD: " << *Inst << " to: "
428 if (!Inst->use_empty()) Inst->replaceAllUsesWith(InVal.first);
429 Inst->eraseFromParent();
436 AvailableLoads->insert(Inst->getOperand(0),
437 std::pair<Value*, unsigned>(Inst, CurrentGeneration));
443 if (Inst->mayReadFromMemory())
447 if (CallValue::canHandle(Inst)) {
450 std::pair<Value*, unsigned> InVal = AvailableCalls->lookup(Inst);
452 DEBUG(dbgs() << "EarlyCSE CSE CALL: " << *Inst << " to: "
454 if (!Inst->use_empty()) Inst->replaceAllUsesWith(InVal.first);
455 Inst->eraseFromParent();
462 AvailableCalls->insert(Inst,
463 std::pair<Value*, unsigned>(Inst, CurrentGeneration));
470 if (Inst->mayWriteToMemory()) {
473 if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
479 << *Inst << '\n');