Home | History | Annotate | Download | only in Scalar

Lines Matching refs:Inst

55   Instruction *Inst;
57 SimpleValue(Instruction *I) : Inst(I) {
58 assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
62 return Inst == DenseMapInfo<Instruction *>::getEmptyKey() ||
63 Inst == DenseMapInfo<Instruction *>::getTombstoneKey();
66 static bool canHandle(Instruction *Inst) {
68 if (CallInst *CI = dyn_cast<CallInst>(Inst))
70 return isa<CastInst>(Inst) || isa<BinaryOperator>(Inst) ||
71 isa<GetElementPtrInst>(Inst) || isa<CmpInst>(Inst) ||
72 isa<SelectInst>(Inst) || isa<ExtractElementInst>(Inst) ||
73 isa<InsertElementInst>(Inst) || isa<ShuffleVectorInst>(Inst) ||
74 isa<ExtractValueInst>(Inst) || isa<InsertValueInst>(Inst);
93 Instruction *Inst = Val.Inst;
95 if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(Inst)) {
104 if (CmpInst *CI = dyn_cast<CmpInst>(Inst)) {
108 if (Inst->getOperand(0) > Inst->getOperand(1)) {
112 return hash_combine(Inst->getOpcode(), Pred, LHS, RHS);
115 if (CastInst *CI = dyn_cast<CastInst>(Inst))
118 if (const ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(Inst))
122 if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(Inst))
127 assert((isa<CallInst>(Inst) || isa<BinaryOperator>(Inst) ||
128 isa<GetElementPtrInst>(Inst) || isa<SelectInst>(Inst) ||
129 isa<ExtractElementInst>(Inst) || isa<InsertElementInst>(Inst) ||
130 isa<ShuffleVectorInst>(Inst)) &&
135 Inst->getOpcode(),
136 hash_combine_range(Inst->value_op_begin(), Inst->value_op_end()));
140 Instruction *LHSI = LHS.Inst, *RHSI = RHS.Inst;
184 Instruction *Inst;
186 CallValue(Instruction *I) : Inst(I) {
187 assert((isSentinel() || canHandle(I)) && "Inst can't be handled!");
191 return Inst == DenseMapInfo<Instruction *>::getEmptyKey() ||
192 Inst == DenseMapInfo<Instruction *>::getTombstoneKey();
195 static bool canHandle(Instruction *Inst) {
197 if (Inst->getType()->isVoidTy())
200 CallInst *CI = dyn_cast<CallInst>(Inst);
222 Instruction *Inst = Val.Inst;
225 Inst->getOpcode(),
226 hash_combine_range(Inst->value_op_begin(), Inst->value_op_end()));
230 Instruction *LHSI = LHS.Inst, *RHSI = RHS.Inst;
290 LoadValue(Instruction *Inst, unsigned Generation, unsigned MatchingId,
292 : DefInst(Inst), Generation(Generation), MatchingId(MatchingId),
386 ParseMemoryInst(Instruction *Inst, const TargetTransformInfo &TTI)
387 : IsTargetMemInst(false), Inst(Inst) {
388 if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst))
394 return isa<LoadInst>(Inst);
398 return isa<StoreInst>(Inst);
405 return Inst->isAtomic();
412 if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
414 } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
418 return !Inst->isAtomic();
426 if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
428 } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
436 if (auto *LI = dyn_cast<LoadInst>(Inst))
441 bool isMatchingMemLoc(const ParseMemoryInst &Inst) const {
442 return (getPointerOperand() == Inst.getPointerOperand() &&
443 getMatchingId() == Inst.getMatchingId());
457 if (LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
459 } else if (StoreInst *SI = dyn_cast<StoreInst>(Inst)) {
466 return Inst->mayReadFromMemory();
470 return Inst->mayWriteToMemory();
476 Instruction *Inst;
481 Value *getOrCreateResult(Value *Inst, Type *ExpectedType) const {
482 if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
484 else if (StoreInst *SI = dyn_cast<StoreInst>(Inst))
486 assert(isa<IntrinsicInst>(Inst) && "Instruction not supported");
487 return TTI.getOrCreateResultFromMemIntrinsic(cast<IntrinsicInst>(Inst),
545 Instruction *Inst = &*I++;
548 if (isInstructionTriviallyDead(Inst, &TLI)) {
549 DEBUG(dbgs() << "EarlyCSE DCE: " << *Inst << '\n');
550 Inst->eraseFromParent();
560 if (match(Inst, m_Intrinsic<Intrinsic::assume>())) {
561 DEBUG(dbgs() << "EarlyCSE skipping assumption: " << *Inst << '\n');
565 if (match(Inst, m_Intrinsic<Intrinsic::experimental_guard>())) {
567 dyn_cast<Instruction>(cast<CallInst>(Inst)->getArgOperand(0))) {
583 if (Value *V = SimplifyInstruction(Inst, DL, &TLI, &DT, &AC)) {
584 DEBUG(dbgs() << "EarlyCSE Simplify: " << *Inst << " to: " << *V << '\n');
585 if (!Inst->use_empty()) {
586 Inst->replaceAllUsesWith(V);
589 if (isInstructionTriviallyDead(Inst, &TLI)) {
590 Inst->eraseFromParent();
600 if (SimpleValue::canHandle(Inst)) {
602 if (Value *V = AvailableValues.lookup(Inst)) {
603 DEBUG(dbgs() << "EarlyCSE CSE: " << *Inst << " to: " << *V << '\n');
605 I->andIRFlags(Inst);
606 Inst->replaceAllUsesWith(V);
607 Inst->eraseFromParent();
614 AvailableValues.insert(Inst, Inst);
618 ParseMemoryInst MemInst(Inst, TTI);
644 Value *Op = getOrCreateResult(InVal.DefInst, Inst->getType());
646 DEBUG(dbgs() << "EarlyCSE CSE LOAD: " << *Inst
648 if (!Inst->use_empty())
649 Inst->replaceAllUsesWith(Op);
650 Inst->eraseFromParent();
660 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
671 if (Inst->mayReadFromMemory() &&
676 if (CallValue::canHandle(Inst)) {
679 std::pair<Instruction *, unsigned> InVal = AvailableCalls.lookup(Inst);
681 DEBUG(dbgs() << "EarlyCSE CSE CALL: " << *Inst
683 if (!Inst->use_empty())
684 Inst->replaceAllUsesWith(InVal.first);
685 Inst->eraseFromParent();
693 Inst, std::pair<Instruction *, unsigned>(Inst, CurrentGeneration));
702 if (FenceInst *FI = dyn_cast<FenceInst>(Inst))
704 assert(Inst->mayReadFromMemory() && "relied on to prevent DSE above");
716 InVal.DefInst == getOrCreateResult(Inst, InVal.DefInst->getType()) &&
725 DEBUG(dbgs() << "EarlyCSE DSE (writeback): " << *Inst << '\n');
726 Inst->eraseFromParent();
738 if (Inst->mayWriteToMemory()) {
756 << " due to: " << *Inst << '\n');
772 LoadValue(Inst, CurrentGeneration, MemInst.getMatchingId(),
783 LastStore = Inst;