Lines Matching full:instruction
64 public InstVisitor<InstCombinerImpl, Instruction *> {
86 // Visitation implementation - Implement instruction combining for different
87 // instruction types. The semantics are as follows:
91 // otherwise - Change was made, replace I with returned instruction
93 Instruction *visitFNeg(UnaryOperator &I);
94 Instruction *visitAdd(BinaryOperator &I);
95 Instruction *visitFAdd(BinaryOperator &I);
98 Instruction *visitSub(BinaryOperator &I);
99 Instruction *visitFSub(BinaryOperator &I);
100 Instruction *visitMul(BinaryOperator &I);
101 Instruction *foldPowiReassoc(BinaryOperator &I);
102 Instruction *foldFMulReassoc(BinaryOperator &I);
103 Instruction *visitFMul(BinaryOperator &I);
104 Instruction *visitURem(BinaryOperator &I);
105 Instruction *visitSRem(BinaryOperator &I);
106 Instruction *visitFRem(BinaryOperator &I);
108 Instruction *commonIRemTransforms(BinaryOperator &I);
109 Instruction *commonIDivTransforms(BinaryOperator &I);
110 Instruction *visitUDiv(BinaryOperator &I);
111 Instruction *visitSDiv(BinaryOperator &I);
112 Instruction *visitFDiv(BinaryOperator &I);
114 Instruction *visitAnd(BinaryOperator &I);
115 Instruction *visitOr(BinaryOperator &I);
116 bool sinkNotIntoLogicalOp(Instruction &I);
117 bool sinkNotIntoOtherHandOfLogicalOp(Instruction &I);
118 Instruction *visitXor(BinaryOperator &I);
119 Instruction *visitShl(BinaryOperator &I);
123 Instruction *canonicalizeCondSignextOfHighBitExtractToSignextHighBitExtract(
125 Instruction *foldVariableSignZeroExtensionOfVariableHighBitExtract(
127 Instruction *visitAShr(BinaryOperator &I);
128 Instruction *visitLShr(BinaryOperator &I);
129 Instruction *commonShiftTransforms(BinaryOperator &I);
130 Instruction *visitFCmpInst(FCmpInst &I);
132 Instruction *visitICmpInst(ICmpInst &I);
133 Instruction *FoldShiftByConstant(Value *Op0, Constant *Op1,
135 Instruction *commonCastTransforms(CastInst &CI);
136 Instruction *visitTrunc(TruncInst &CI);
137 Instruction *visitZExt(ZExtInst &Zext);
138 Instruction *visitSExt(SExtInst &Sext);
139 Instruction *visitFPTrunc(FPTruncInst &CI);
140 Instruction *visitFPExt(CastInst &CI);
141 Instruction *visitFPToUI(FPToUIInst &FI);
142 Instruction *visitFPToSI(FPToSIInst &FI);
143 Instruction *visitUIToFP(CastInst &CI);
144 Instruction *visitSIToFP(CastInst &CI);
145 Instruction *visitPtrToInt(PtrToIntInst &CI);
146 Instruction *visitIntToPtr(IntToPtrInst &CI);
147 Instruction *visitBitCast(BitCastInst &CI);
148 Instruction *visitAddrSpaceCast(AddrSpaceCastInst &CI);
149 Instruction *foldItoFPtoI(CastInst &FI);
150 Instruction *visitSelectInst(SelectInst &SI);
151 Instruction *visitCallInst(CallInst &CI);
152 Instruction *visitInvokeInst(InvokeInst &II);
153 Instruction *visitCallBrInst(CallBrInst &CBI);
155 Instruction *SliceUpIllegalIntegerPHI(PHINode &PN);
156 Instruction *visitPHINode(PHINode &PN);
157 Instruction *visitGetElementPtrInst(GetElementPtrInst &GEP);
158 Instruction *visitGEPOfGEP(GetElementPtrInst &GEP, GEPOperator *Src);
159 Instruction *visitAllocaInst(AllocaInst &AI);
160 Instruction *visitAllocSite(Instruction &FI);
161 Instruction *visitFree(CallInst &FI, Value *FreedOp);
162 Instruction *visitLoadInst(LoadInst &LI);
163 Instruction *visitStoreInst(StoreInst &SI);
164 Instruction *visitAtomicRMWInst(AtomicRMWInst &SI);
165 Instruction *visitUnconditionalBranchInst(BranchInst &BI);
166 Instruction *visitBranchInst(BranchInst &BI);
167 Instruction *visitFenceInst(FenceInst &FI);
168 Instruction *visitSwitchInst(SwitchInst &SI);
169 Instruction *visitReturnInst(ReturnInst &RI);
170 Instruction *visitUnreachableInst(UnreachableInst &I);
171 Instruction *
173 Instruction *visitInsertValueInst(InsertValueInst &IV);
174 Instruction *visitInsertElementInst(InsertElementInst &IE);
175 Instruction *visitExtractElementInst(ExtractElementInst &EI);
176 Instruction *simplifyBinOpSplats(ShuffleVectorInst &SVI);
177 Instruction *visitShuffleVectorInst(ShuffleVectorInst &SVI);
178 Instruction *visitExtractValueInst(ExtractValueInst &EV);
179 Instruction *visitLandingPadInst(LandingPadInst &LI);
180 Instruction *visitVAEndInst(VAEndInst &I);
183 Instruction *foldFreezeIntoRecurrence(FreezeInst &I, PHINode *PN);
184 Instruction *visitFreeze(FreezeInst &I);
187 Instruction *visitInstruction(Instruction &I) { return nullptr; }
192 bool dominatesAllUses(const Instruction *DI, const Instruction *UI,
204 const Instruction *CtxI = nullptr,
213 const Instruction *CtxI = nullptr,
222 const Instruction *CtxI) const;
234 return getLosslessTrunc(C, TruncTy, Instruction::ZExt);
238 return getLosslessTrunc(C, TruncTy, Instruction::SExt);
242 convertOrOfShiftsToFunnelShift(Instruction &Or);
266 /// then CtxI has to be the call instruction calling that intrinsic. If this
268 /// to be the arithmetic instruction.
274 bool OptimizeOverflowCheck(Instruction::BinaryOps BinaryOp, bool IsSigned,
276 Instruction &CtxI, Value *&OperationResult,
279 Instruction *visitCallBase(CallBase &Call);
280 Instruction *tryOptimizeCall(CallInst *CI);
282 Instruction *transformCallThroughTrampoline(CallBase &Call,
295 Instruction *simplifyMaskedStore(IntrinsicInst &II);
296 Instruction *simplifyMaskedGather(IntrinsicInst &II);
297 Instruction *simplifyMaskedScatter(IntrinsicInst &II);
306 /// transformation can be performed the new instruction that replaces the
308 Instruction *transformZExtICmp(ICmpInst *Cmp, ZExtInst &Zext);
310 Instruction *transformSExtICmp(ICmpInst *Cmp, SExtInst &Sext);
314 const Instruction &CxtI) const {
321 const Instruction &CxtI) const {
327 const Instruction &CxtI, bool IsSigned) const {
333 const Instruction &CxtI) const {
339 const Instruction &CxtI) const {
345 const Instruction &CxtI, bool IsSigned) const {
351 const Instruction &CxtI) const {
357 const Instruction &CxtI,
364 const Instruction &CxtI, bool IsSigned) const {
370 const Value *RHS, const Instruction &CxtI,
373 case Instruction::Add: return willNotOverflowAdd(LHS, RHS, CxtI, IsSigned);
374 case Instruction::Sub: return willNotOverflowSub(LHS, RHS, CxtI, IsSigned);
375 case Instruction::Mul: return willNotOverflowMul(LHS, RHS, CxtI, IsSigned);
381 Instruction *scalarizePHI(ExtractElementInst &EI, PHINode *PN);
382 Instruction *foldBitcastExtElt(ExtractElementInst &ExtElt);
383 Instruction *foldCastedBitwiseLogic(BinaryOperator &I);
384 Instruction *foldFBinOpOfIntCasts(BinaryOperator &I);
386 Instruction *foldFBinOpOfIntCastsFromSign(
389 Instruction *foldBinopOfSextBoolToSelect(BinaryOperator &I);
390 Instruction *narrowBinOp(TruncInst &Trunc);
391 Instruction *narrowMaskedBinOp(BinaryOperator &And);
392 Instruction *narrowMathIfNoOverflow(BinaryOperator &I);
393 Instruction *narrowFunnelShift(TruncInst &Trunc);
394 Instruction *optimizeBitCastFromPhi(CastInst &CI, PHINode *PN);
395 Instruction *matchSAddSubSat(IntrinsicInst &MinMax1);
396 Instruction *foldNot(BinaryOperator &I);
397 Instruction *foldBinOpOfDisplacedShifts(BinaryOperator &I);
405 /// Instruction::CastOps value for a cast that can replace the pair, casting
409 Instruction::CastOps isEliminableCastPair(const CastInst *CI1,
413 Value *foldAndOrOfICmps(ICmpInst *LHS, ICmpInst *RHS, Instruction &I,
428 Instruction *foldLogicOfIsFPClass(BinaryOperator &Operator, Value *LHS,
431 Instruction *
435 Instruction *CxtI, bool IsAnd,
441 Instruction *foldLShrOverflowBit(BinaryOperator &I);
442 Instruction *foldExtractOfOverflowIntrinsic(ExtractValueInst &EV);
443 Instruction *foldIntrinsicWithOverflowCommon(IntrinsicInst *II);
444 Instruction *foldIntrinsicIsFPClass(IntrinsicInst &II);
445 Instruction *foldFPSignBitOps(BinaryOperator &I);
446 Instruction *foldFDivConstantDivisor(BinaryOperator &I);
451 // into simplier select instruction using isImpliedCondition.
452 Instruction *foldAndOrOfSelectUsingImpliedCond(Value *Op, SelectInst &SI,
455 Instruction *hoistFNegAboveFMulFDiv(Value *FNegOp, Instruction &FMFSource);
460 void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
468 /// Combiner aware instruction erasure.
470 /// When dealing with an instruction that has side effects or produces a void
471 /// value, we can't rely on DCE to delete the instruction. Instead, visit
473 Instruction *eraseInstFromFunction(Instruction &I) override {
475 assert(I.use_empty() && "Cannot erase instruction that is used!");
491 Instruction::BinaryOps BinaryOp, bool IsSigned,
492 Value *LHS, Value *RHS, Instruction *CxtI) const;
521 Instruction *tryFoldInstWithCtpopWithNot(Instruction *I);
527 Instruction *foldBinOpShiftWithShift(BinaryOperator &I);
533 Instruction *foldBinOpOfSelectAndCastOfSelectCondition(BinaryOperator &I);
550 Value *SimplifyDemandedUseBits(Instruction *I, const APInt &DemandedMask,
554 bool SimplifyDemandedBits(Instruction *I, unsigned Op,
560 /// DemandedMask, but without modifying the Instruction.
561 Value *SimplifyMultipleUseDemandedBits(Instruction *I,
567 /// bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
569 Instruction *Shr, const APInt &ShrOp1, Instruction *Shl,
572 /// Tries to simplify operands to an integer instruction based on its
574 bool SimplifyDemandedInstructionBits(Instruction &Inst);
575 bool SimplifyDemandedInstructionBits(Instruction &Inst, KnownBits &Known);
585 Instruction *CxtI);
586 bool SimplifyDemandedFPClass(Instruction *I, unsigned Op,
591 Instruction *foldVectorBinop(BinaryOperator &Inst);
592 Instruction *foldVectorSelect(SelectInst &Sel);
593 Instruction *foldSelectShuffle(ShuffleVectorInst &Shuf);
595 /// Given a binary operator, cast instruction, or select which has a PHI node
596 /// as operand #0, see if we can fold the instruction into the PHI (which is
598 Instruction *foldOpIntoPhi(Instruction &I, PHINode *PN);
608 Instruction *foldBinopWithPhiOperands(BinaryOperator &BO);
610 /// Given an instruction with a select as one operand and a constant as the
614 Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
618 Instruction *foldBinOpIntoSelectOrPhi(BinaryOperator &I);
620 Instruction *foldAddWithConstant(BinaryOperator &Add);
622 Instruction *foldSquareSumInt(BinaryOperator &I);
623 Instruction *foldSquareSumFP(BinaryOperator &I);
627 Instruction *foldPHIArgOpIntoPHI(PHINode &PN);
628 Instruction *foldPHIArgBinOpIntoPHI(PHINode &PN);
629 Instruction *foldPHIArgInsertValueInstructionIntoPHI(PHINode &PN);
630 Instruction *foldPHIArgExtractValueInstructionIntoPHI(PHINode &PN);
631 Instruction *foldPHIArgGEPIntoPHI(PHINode &PN);
632 Instruction *foldPHIArgLoadIntoPHI(PHINode &PN);
633 Instruction *foldPHIArgZextsIntoPHI(PHINode &PN);
634 Instruction *foldPHIArgIntToPtrToPHI(PHINode &PN);
643 void PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN);
645 Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
646 ICmpInst::Predicate Cond, Instruction &I);
647 Instruction *foldSelectICmp(ICmpInst::Predicate Pred, SelectInst *SI,
650 Instruction *foldCmpLoadFromIndexedGlobal(LoadInst *LI,
654 Instruction *foldFCmpIntToFPConst(FCmpInst &I, Instruction *LHSI,
656 Instruction *foldICmpAddOpConst(Value *X, const APInt &C,
658 Instruction *foldICmpWithCastOp(ICmpInst &ICmp);
659 Instruction *foldICmpWithZextOrSext(ICmpInst &ICmp);
661 Instruction *foldICmpUsingKnownBits(ICmpInst &Cmp);
662 Instruction *foldICmpWithDominatingICmp(ICmpInst &Cmp);
663 Instruction *foldICmpWithConstant(ICmpInst &Cmp);
664 Instruction *foldICmpUsingBoolRange(ICmpInst &I);
665 Instruction *foldICmpInstWithConstant(ICmpInst &Cmp);
666 Instruction *foldICmpInstWithConstantNotInt(ICmpInst &Cmp);
667 Instruction *foldICmpInstWithConstantAllowPoison(ICmpInst &Cmp,
669 Instruction *foldICmpBinOp(ICmpInst &Cmp, const SimplifyQuery &SQ);
670 Instruction *foldICmpWithMinMax(Instruction &I, MinMaxIntrinsic *MinMax,
672 Instruction *foldICmpEquality(ICmpInst &Cmp);
673 Instruction *foldIRemByPowerOfTwoToBitTest(ICmpInst &I);
674 Instruction *foldSignBitTest(ICmpInst &I);
675 Instruction *foldICmpWithZero(ICmpInst &Cmp);
679 Instruction *foldICmpBinOpWithConstant(ICmpInst &Cmp, BinaryOperator *BO,
681 Instruction *foldICmpSelectConstant(ICmpInst &Cmp, SelectInst *Select,
683 Instruction *foldICmpTruncConstant(ICmpInst &Cmp, TruncInst *Trunc,
685 Instruction *foldICmpTruncWithTruncOrExt(ICmpInst &Cmp,
687 Instruction *foldICmpAndConstant(ICmpInst &Cmp, BinaryOperator *And,
689 Instruction *foldICmpXorConstant(ICmpInst &Cmp, BinaryOperator *Xor,
691 Instruction *foldICmpOrConstant(ICmpInst &Cmp, BinaryOperator *Or,
693 Instruction *foldICmpMulConstant(ICmpInst &Cmp, BinaryOperator *Mul,
695 Instruction *foldICmpShlConstant(ICmpInst &Cmp, BinaryOperator *Shl,
697 Instruction *foldICmpShrConstant(ICmpInst &Cmp, BinaryOperator *Shr,
699 Instruction *foldICmpSRemConstant(ICmpInst &Cmp, BinaryOperator *UDiv,
701 Instruction *foldICmpUDivConstant(ICmpInst &Cmp, BinaryOperator *UDiv,
703 Instruction *foldICmpDivConstant(ICmpInst &Cmp, BinaryOperator *Div,
705 Instruction *foldICmpSubConstant(ICmpInst &Cmp, BinaryOperator *Sub,
707 Instruction *foldICmpAddConstant(ICmpInst &Cmp, BinaryOperator *Add,
709 Instruction *foldICmpAndConstConst(ICmpInst &Cmp, BinaryOperator *And,
711 Instruction *foldICmpAndShift(ICmpInst &Cmp, BinaryOperator *And,
713 Instruction *foldICmpXorShiftConst(ICmpInst &Cmp, BinaryOperator *Xor,
715 Instruction *foldICmpShrConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
717 Instruction *foldICmpShlConstConst(ICmpInst &I, Value *ShAmt, const APInt &C1,
720 Instruction *foldICmpBinOpEqualityWithConstant(ICmpInst &Cmp,
723 Instruction *foldICmpIntrinsicWithConstant(ICmpInst &ICI, IntrinsicInst *II,
725 Instruction *foldICmpEqIntrinsicWithConstant(ICmpInst &ICI, IntrinsicInst *II,
727 Instruction *foldICmpBitCast(ICmpInst &Cmp);
728 Instruction *foldICmpWithTrunc(ICmpInst &Cmp);
729 Instruction *foldICmpCommutative(ICmpInst::Predicate Pred, Value *Op0,
733 Instruction *foldSelectOfBools(SelectInst &SI);
734 Instruction *foldSelectExtConst(SelectInst &Sel);
735 Instruction *foldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI);
736 Instruction *foldSelectIntoOp(SelectInst &SI, Value *, Value *);
737 Instruction *foldSPFofSPF(Instruction *Inner, SelectPatternFlavor SPF1,
738 Value *A, Value *B, Instruction &Outer,
740 Instruction *foldSelectInstWithICmp(SelectInst &SI, ICmpInst *ICI);
741 Instruction *foldSelectValueEquivalence(SelectInst &SI, ICmpInst &ICI);
749 /// Given an initial instruction, check to see if it is the root of a
752 Instruction *matchBSwapOrBitReverse(Instruction &I, bool MatchBSwaps,
755 Instruction *SimplifyAnyMemTransfer(AnyMemTransferInst *MI);
756 Instruction *SimplifyAnyMemSet(AnyMemSetInst *MI);
760 bool tryToSinkInstruction(Instruction *I, BasicBlock *DestBlock);
762 Instruction *I, BasicBlock::iterator InsertPos, BasicBlock *SrcBlock,
765 Instruction *I, BasicBlock::iterator InsertPos, BasicBlock *SrcBlock,
768 bool removeInstructionsBeforeUnreachable(Instruction &I);
771 void handleUnreachableFrom(Instruction *I,
779 /// Top-to-bottom, def-to-use negated instruction tree we produced.
780 SmallVector<Instruction *, NegatorMaxNodesSSO> NewInstructions;
796 using Result = std::pair<ArrayRef<Instruction *> /*NewInstructions*/,
799 std::array<Value *, 2> getSortedOperandsOfBinOp(Instruction *I);