Home | History | Annotate | Download | only in InstCombine

Lines Matching full:instruction

116 /// isSignBitCheck - Given an exploded icmp instruction, return true if the
229 Instruction *InstCombiner::
605 /// FoldGEPICmp - Fold comparisons between a GEP instruction and something
607 Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
609 Instruction &I) {
741 Instruction *InstCombiner::FoldICmpAddOpCst(Instruction &ICI,
790 Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
803 bool DivIsSigned = DivI->getOpcode() == Instruction::SDiv;
824 // as in the LHS instruction that we're folding.
947 Instruction *InstCombiner::FoldICmpShrCst(ICmpInst &ICI, BinaryOperator *Shr,
962 if (ICI.isSigned() != (Shr->getOpcode() == Instruction::AShr))
968 if (Shr->getOpcode() == Instruction::AShr &&
979 Shr->getOpcode() == Instruction::AShr ?
991 assert(TheDiv->getOpcode() == Instruction::SDiv ||
992 TheDiv->getOpcode() == Instruction::UDiv);
994 Instruction *Res = FoldICmpDivCst(ICI, TheDiv, cast<ConstantInt>(DivCst));
1004 if (Shr->getOpcode() == Instruction::LShr)
1036 Instruction *InstCombiner::FoldICmpCstShrCst(ICmpInst &I, Value *Op, Value *A,
1096 Instruction *InstCombiner::FoldICmpCstShlCst(ICmpInst &I, Value *Op, Value *A,
1141 Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
1142 Instruction *LHSI,
1147 case Instruction::Trunc:
1167 case Instruction::Xor: // (icmp pred (xor X, XorCst), CI)
1233 case Instruction::And: // (icmp pred (and X, AndCst), RHS)
1290 if (ShiftOpcode == Instruction::AShr) {
1294 } else if (ShiftOpcode == Instruction::Shl) {
1302 } else if (ShiftOpcode == Instruction::LShr) {
1323 if (ShiftOpcode == Instruction::Shl)
1341 if (ShiftOpcode == Instruction::Shl)
1361 if (Shift->getOpcode() == Instruction::LShr) {
1437 if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV,ICI, C))
1452 case Instruction::Or: {
1463 Instruction *Op;
1473 case Instruction::Mul: { // (icmp pred (mul X, Val), CI)
1490 case Instruction::Shl: { // (icmp pred (shl X, ShAmt), CI)
1644 case Instruction::LShr: // (icmp pred (shr X, ShAmt), CI)
1645 case Instruction::AShr: {
1649 if (Instruction *Res = FoldICmpShrCst(ICI, BO, ShAmt))
1661 case Instruction::SDiv:
1662 case Instruction::UDiv:
1670 if (Instruction *R = FoldICmpDivCst(ICI, cast<BinaryOperator>(LHSI),
1675 case Instruction::Sub: {
1699 case Instruction::Add:
1756 case Instruction::SRem:
1769 case Instruction::Add:
1791 case Instruction::Xor:
1803 case Instruction::Sub:
1815 case Instruction::Or:
1825 case Instruction::And:
1861 case Instruction::Mul:
1913 Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
1922 if (LHSCI->getOpcode() == Instruction::PtrToInt &&
1943 if (LHSCI->getOpcode() != Instruction::ZExt &&
1944 LHSCI->getOpcode() != Instruction::SExt)
1947 bool isSignedExt = LHSCI->getOpcode() == Instruction::SExt;
2031 static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
2041 Instruction *AddWithCst = cast<Instruction>(I.getOperand(0));
2069 Instruction *OrigAdd = cast<Instruction>(AddWithCst->getOperand(0));
2113 Value *RHS, Instruction &OrigI,
2228 /// \param I Compare instruction.
2229 /// \param MulVal Result of 'mult' instruction. It is one of the arguments of
2230 /// the compare instruction. Must be of integer type.
2231 /// \param OtherVal The other argument of compare instruction.
2232 /// \returns Instruction which must replace the compare instruction, NULL if no
2234 static Instruction *ProcessUMulZExtIdiom(ICmpInst &I, Value *MulVal,
2243 Instruction *MulInstr = cast<Instruction>(MulVal);
2244 assert(MulInstr->getOpcode() == Instruction::Mul);
2248 assert(LHS->getOpcode() == Instruction::ZExt);
2249 assert(RHS->getOpcode() == Instruction::ZExt);
2280 if (BO->getOpcode() != Instruction::And)
2404 assert(BO->getOpcode() == Instruction::And);
2409 Instruction *Zext =
2410 cast<Instruction>(Builder->CreateZExt(ShortAnd, BO->getType()));
2416 IC.Worklist.Add(cast<Instruction>(U));
2419 if (isa<Instruction>(OtherVal))
2420 IC.Worklist.Add(cast<Instruction>(OtherVal));
2495 /// The rational is that several architectures use the same instruction for
2515 if (!BinOp || BinOp->getOpcode() != Instruction::Sub)
2542 bool InstCombiner::dominatesAllUses(const Instruction *DI,
2543 const Instruction *UI,
2545 assert(DI && UI && "Instruction not defined\n");
2559 auto *Usr = cast<Instruction>(U);
2567 /// true when the instruction sequence within a block is select-cmp-br.
2587 /// \param SI Select instruction
2588 /// \param Icmp Compare instruction
2648 Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
2677 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
2681 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
2691 default: llvm_unreachable("Invalid icmp instruction!");
2758 if (Instruction *Res = ProcessUGT_ADDCST_ADD(I, A, B, CI2, CI, *this))
2791 // If we have an icmp le or icmp ge instruction, turn it into the
2792 // appropriate icmp lt or icmp gt instruction. This allows us to rely on
2820 if (Instruction *Inst = FoldICmpCstShrCst(I, Op0, A, CI, CI2))
2825 if (Instruction *Inst = FoldICmpCstShlCst(I, Op0, A, CI, CI2))
3074 // Test if the ICmpInst instruction is used exclusively by a select as
3087 // See if we are doing a comparison between a constant and an instruction that
3091 // instruction, see if that instruction also has constants so that the
3092 // instruction can be folded into the icmp
3093 if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
3094 if (Instruction *Res = visitICmpInstWithInstAndIntCst(I, LHSI, CI))
3100 if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
3102 case Instruction::GetElementPtr:
3109 case Instruction::PHI:
3114 if (Instruction *NV = FoldOpIntoPhi(I))
3117 case Instruction::Select: {
3165 case Instruction::IntToPtr:
3173 case Instruction::Load:
3180 if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV, I))
3189 if (Instruction *NI = FoldGEPICmp(GEP, Op1, I.getPredicate(), I))
3192 if (Instruction *NI = FoldGEPICmp(GEP, Op0,
3206 // If operand #1 is a bitcast instruction, it must also be a ptr->ptr cast
3232 if (Instruction *R = visitICmpInstWithCastAndCast(I))
3251 // Analyze the case when either Op0 or Op1 is an add instruction.
3254 if (BO0 && BO0->getOpcode() == Instruction::Add)
3256 if (BO1 && BO1->getOpcode() == Instruction::Add)
3352 // Analyze the case when either Op0 or Op1 is a sub instruction.
3355 if (BO0 && BO0->getOpcode() == Instruction::Sub)
3357 if (BO1 && BO1->getOpcode() == Instruction::Sub)
3392 if (BO0 && BO0->getOpcode() == Instruction::SRem &&
3396 else if (BO1 && BO1->getOpcode() == Instruction::SRem &&
3401 // the value we use is the same value this instruction was already using.
3424 case Instruction::Add:
3425 case Instruction::Sub:
3426 case Instruction::Xor:
3450 case Instruction::Mul:
3469 case Instruction::UDiv:
3470 case Instruction::LShr:
3474 case Instruction::SDiv:
3475 case Instruction::AShr:
3480 case Instruction::Shl: {
3514 Instruction *AddI = nullptr;
3529 if (Instruction *R = ProcessUMulZExtIdiom(I, Op0, Op1, *this))
3533 if (Instruction *R = ProcessUMulZExtIdiom(I, Op1, Op0, *this))
3673 // The 'cmpxchg' instruction returns an aggregate containing the old value and
3703 Instruction *InstCombiner::FoldFCmp_IntToFP_Cst(FCmpInst &I,
3704 Instruction *LHSI,
3721 // If this is a uitofp instruction, we need an extra bit to hold the sign.
3933 Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
3975 if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
3977 case Instruction::FPExt: {
4017 case Instruction::PHI:
4022 if (Instruction *NV = FoldOpIntoPhi(I))
4025 case Instruction::SIToFP:
4026 case Instruction::UIToFP:
4027 if (Instruction *NV = FoldFCmp_IntToFP_Cst(I, LHSI, RHSC))
4030 case Instruction::FSub: {
4038 case Instruction::Load:
4044 if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV, I))
4048 case Instruction::Call: {