Lines Matching refs:Cmp

936         Value *Cmp = Builder.CreateICmp(ICmpInst::getSignedPredicate(Cond),  in foldGEPICmp()  local
938 return replaceInstUsesWith(I, Cmp); in foldGEPICmp()
1376 Instruction *InstCombinerImpl::foldICmpWithZero(ICmpInst &Cmp) { in foldICmpWithZero() argument
1377 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithZero()
1378 if (!match(Cmp.getOperand(1), m_Zero())) in foldICmpWithZero()
1384 if (match(Cmp.getOperand(0), m_SMin(m_Value(A), m_Value(B)))) { in foldICmpWithZero()
1385 if (isKnownPositive(A, DL, 0, &AC, &Cmp, &DT)) in foldICmpWithZero()
1386 return new ICmpInst(Pred, B, Cmp.getOperand(1)); in foldICmpWithZero()
1387 if (isKnownPositive(B, DL, 0, &AC, &Cmp, &DT)) in foldICmpWithZero()
1388 return new ICmpInst(Pred, A, Cmp.getOperand(1)); in foldICmpWithZero()
1392 if (Instruction *New = foldIRemByPowerOfTwoToBitTest(Cmp)) in foldICmpWithZero()
1400 if (match(Cmp.getOperand(0), m_URem(m_Value(X), m_Value(Y))) && in foldICmpWithZero()
1402 KnownBits XKnown = computeKnownBits(X, 0, &Cmp); in foldICmpWithZero()
1403 KnownBits YKnown = computeKnownBits(Y, 0, &Cmp); in foldICmpWithZero()
1405 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1416 Instruction *InstCombinerImpl::foldICmpWithConstant(ICmpInst &Cmp) { in foldICmpWithConstant() argument
1428 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithConstant()
1429 Value *Op0 = Cmp.getOperand(0), *Op1 = Cmp.getOperand(1); in foldICmpWithConstant()
1434 if (Instruction *Res = processUGT_ADDCST_ADD(Cmp, A, B, CI2, CI, *this)) in foldICmpWithConstant()
1444 Type *Ty = Cmp.getType(); in foldICmpWithConstant()
1454 NewPhi->takeName(&Cmp); in foldICmpWithConstant()
1455 return replaceInstUsesWith(Cmp, NewPhi); in foldICmpWithConstant()
1462 Instruction *InstCombinerImpl::foldICmpWithDominatingICmp(ICmpInst &Cmp) { in foldICmpWithDominatingICmp() argument
1465 BasicBlock *CmpBB = Cmp.getParent(); in foldICmpWithDominatingICmp()
1483 Optional<bool> Imp = isImpliedCondition(DomCond, &Cmp, DL, TrueBB == CmpBB); in foldICmpWithDominatingICmp()
1485 return replaceInstUsesWith(Cmp, ConstantInt::get(Cmp.getType(), *Imp)); in foldICmpWithDominatingICmp()
1487 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithDominatingICmp()
1488 Value *X = Cmp.getOperand(0), *Y = Cmp.getOperand(1); in foldICmpWithDominatingICmp()
1508 return replaceInstUsesWith(Cmp, Builder.getFalse()); in foldICmpWithDominatingICmp()
1510 return replaceInstUsesWith(Cmp, Builder.getTrue()); in foldICmpWithDominatingICmp()
1519 if (Cmp.isEquality() || (IsSignBit && hasBranchUse(Cmp))) in foldICmpWithDominatingICmp()
1524 if (Cmp.hasOneUse() && in foldICmpWithDominatingICmp()
1525 match(Cmp.user_back(), m_MaxOrMin(m_Value(), m_Value()))) in foldICmpWithDominatingICmp()
1538 Instruction *InstCombinerImpl::foldICmpTruncConstant(ICmpInst &Cmp, in foldICmpTruncConstant() argument
1541 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpTruncConstant()
1553 if (Cmp.isEquality() && Trunc->hasOneUse()) { in foldICmpTruncConstant()
1566 KnownBits Known = computeKnownBits(X, 0, &Cmp); in foldICmpTruncConstant()
1597 Instruction *InstCombinerImpl::foldICmpXorConstant(ICmpInst &Cmp, in foldICmpXorConstant() argument
1608 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpXorConstant()
1610 if (isSignBitCheck(Cmp.getPredicate(), C, TrueIfSigned)) { in foldICmpXorConstant()
1615 return replaceOperand(Cmp, 0, X); in foldICmpXorConstant()
1628 if (!Cmp.isEquality() && XorC->isSignMask()) { in foldICmpXorConstant()
1629 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1634 if (!Cmp.isEquality() && XorC->isMaxSignedValue()) { in foldICmpXorConstant()
1635 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1636 Pred = Cmp.getSwappedPredicate(Pred); in foldICmpXorConstant()
1664 Instruction *InstCombinerImpl::foldICmpAndShift(ICmpInst &Cmp, in foldICmpAndShift() argument
1688 if (Cmp.isSigned() && (C2.isNegative() || C1.isNegative())) in foldICmpAndShift()
1702 if (Cmp.isSigned() && (NewAndCst.isNegative() || NewCmpCst.isNegative())) in foldICmpAndShift()
1719 if (Cmp.getPredicate() == ICmpInst::ICMP_EQ) in foldICmpAndShift()
1720 return replaceInstUsesWith(Cmp, ConstantInt::getFalse(Cmp.getType())); in foldICmpAndShift()
1721 if (Cmp.getPredicate() == ICmpInst::ICMP_NE) in foldICmpAndShift()
1722 return replaceInstUsesWith(Cmp, ConstantInt::getTrue(Cmp.getType())); in foldICmpAndShift()
1726 return new ICmpInst(Cmp.getPredicate(), in foldICmpAndShift()
1734 if (Shift->hasOneUse() && C1.isZero() && Cmp.isEquality() && in foldICmpAndShift()
1743 return replaceOperand(Cmp, 0, NewAnd); in foldICmpAndShift()
1750 Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp, in foldICmpAndConstConst() argument
1753 bool isICMP_NE = Cmp.getPredicate() == ICmpInst::ICMP_NE; in foldICmpAndConstConst()
1758 if (isICMP_NE && Cmp.getType()->isVectorTy() && C1.isZero() && in foldICmpAndConstConst()
1760 return new TruncInst(And->getOperand(0), Cmp.getType()); in foldICmpAndConstConst()
1771 if (Cmp.isEquality() && C1.isZero()) { in foldICmpAndConstConst()
1805 (Cmp.isEquality() || (!C1.isNegative() && !C2->isNegative()))) { in foldICmpAndConstConst()
1809 if (!Cmp.getType()->isVectorTy()) { in foldICmpAndConstConst()
1815 return new ICmpInst(Cmp.getPredicate(), NewAnd, ZextC1); in foldICmpAndConstConst()
1819 if (Instruction *I = foldICmpAndShift(Cmp, And, C1, *C2)) in foldICmpAndConstConst()
1826 if (!Cmp.isSigned() && C1.isZero() && And->getOperand(0)->hasOneUse() && in foldICmpAndConstConst()
1854 return replaceOperand(Cmp, 0, NewAnd); in foldICmpAndConstConst()
1863 Instruction *InstCombinerImpl::foldICmpAndConstant(ICmpInst &Cmp, in foldICmpAndConstant() argument
1866 if (Instruction *I = foldICmpAndConstConst(Cmp, And, C)) in foldICmpAndConstant()
1869 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAndConstant()
1892 foldCmpLoadFromIndexedGlobal(LI, GEP, GV, Cmp, C2)) in foldICmpAndConstant()
1895 if (!Cmp.isEquality()) in foldICmpAndConstant()
1901 if (Cmp.getOperand(1) == Y && C.isNegatedPowerOf2()) { in foldICmpAndConstant()
1904 return new ICmpInst(NewPred, X, SubOne(cast<Constant>(Cmp.getOperand(1)))); in foldICmpAndConstant()
1911 Instruction *InstCombinerImpl::foldICmpOrConstant(ICmpInst &Cmp, in foldICmpOrConstant() argument
1914 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpOrConstant()
1925 if (match(OrOp1, m_APInt(MaskC)) && Cmp.isEquality()) { in foldICmpOrConstant()
1956 if (!Cmp.isEquality() || !C.isZero() || !Or->hasOneUse()) in foldICmpOrConstant()
1988 Instruction *InstCombinerImpl::foldICmpMulConstant(ICmpInst &Cmp, in foldICmpMulConstant() argument
1997 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpMulConstant()
2010 if (Cmp.isEquality()) { in foldICmpMulConstant()
2058 static Instruction *foldICmpShlOne(ICmpInst &Cmp, Instruction *Shl, in foldICmpShlOne() argument
2067 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlOne()
2068 if (Cmp.isUnsigned()) { in foldICmpShlOne()
2091 } else if (Cmp.isSigned()) { in foldICmpShlOne()
2112 } else if (Cmp.isEquality() && CIsPowerOf2) { in foldICmpShlOne()
2120 Instruction *InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp, in foldICmpShlConstant() argument
2124 if (Cmp.isEquality() && match(Shl->getOperand(0), m_APInt(ShiftVal))) in foldICmpShlConstant()
2125 return foldICmpShlConstConst(Cmp, Shl->getOperand(1), C, *ShiftVal); in foldICmpShlConstant()
2129 return foldICmpShlOne(Cmp, Shl, C); in foldICmpShlConstant()
2137 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlConstant()
2196 if (Cmp.isEquality() && Shl->hasOneUse()) { in foldICmpShlConstant()
2219 if (Cmp.isUnsigned() && Shl->hasOneUse()) { in foldICmpShlConstant()
2248 Type *TruncTy = IntegerType::get(Cmp.getContext(), TypeBits - Amt); in foldICmpShlConstant()
2260 Instruction *InstCombinerImpl::foldICmpShrConstant(ICmpInst &Cmp, in foldICmpShrConstant() argument
2266 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShrConstant()
2267 if (Cmp.isEquality() && Shr->isExact() && C.isZero()) in foldICmpShrConstant()
2268 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpShrConstant()
2273 if (Cmp.isEquality()) in foldICmpShrConstant()
2274 return foldICmpShrConstConst(Cmp, Shr->getOperand(1), C, *ShiftValC); in foldICmpShrConstant()
2376 if (!Cmp.isEquality()) in foldICmpShrConstant()
2415 Instruction *InstCombinerImpl::foldICmpSRemConstant(ICmpInst &Cmp, in foldICmpSRemConstant() argument
2421 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSRemConstant()
2466 Instruction *InstCombinerImpl::foldICmpUDivConstant(ICmpInst &Cmp, in foldICmpUDivConstant() argument
2469 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpUDivConstant()
2499 Instruction *InstCombinerImpl::foldICmpDivConstant(ICmpInst &Cmp, in foldICmpDivConstant() argument
2502 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpDivConstant()
2516 if (Cmp.isEquality() && Div->hasOneUse() && C.isSignBitSet() && in foldICmpDivConstant()
2542 if (!Cmp.isEquality() && DivIsSigned != Cmp.isSigned()) in foldICmpDivConstant()
2639 return replaceInstUsesWith(Cmp, Builder.getFalse()); in foldICmpDivConstant()
2647 Cmp, insertRangeTest(X, LoBound, HiBound, DivIsSigned, true)); in foldICmpDivConstant()
2650 return replaceInstUsesWith(Cmp, Builder.getTrue()); in foldICmpDivConstant()
2658 Cmp, insertRangeTest(X, LoBound, HiBound, DivIsSigned, false)); in foldICmpDivConstant()
2662 return replaceInstUsesWith(Cmp, Builder.getTrue()); in foldICmpDivConstant()
2664 return replaceInstUsesWith(Cmp, Builder.getFalse()); in foldICmpDivConstant()
2669 return replaceInstUsesWith(Cmp, Builder.getFalse()); in foldICmpDivConstant()
2671 return replaceInstUsesWith(Cmp, Builder.getTrue()); in foldICmpDivConstant()
2681 Instruction *InstCombinerImpl::foldICmpSubConstant(ICmpInst &Cmp, in foldICmpSubConstant() argument
2685 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSubConstant()
2691 if (Cmp.isEquality() && match(X, m_ImmConstant(SubC))) { in foldICmpSubConstant()
2699 ICmpInst::Predicate SwappedPred = Cmp.getSwappedPredicate(); in foldICmpSubConstant()
2703 ((Cmp.isUnsigned() && HasNUW) || (Cmp.isSigned() && HasNSW)) && in foldICmpSubConstant()
2704 !subWithOverflow(SubResult, *C2, C, Cmp.isSigned())) in foldICmpSubConstant()
2713 if (Cmp.isEquality() && C.isZero() && in foldICmpSubConstant()
2766 Instruction *InstCombinerImpl::foldICmpAddConstant(ICmpInst &Cmp, in foldICmpAddConstant() argument
2771 if (Cmp.isEquality() || !match(Y, m_APInt(C2))) in foldICmpAddConstant()
2777 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAddConstant()
2788 Cmp.isSigned() ? C.ssub_ov(*C2, Overflow) : C.usub_ov(*C2, Overflow); in foldICmpAddConstant()
2800 if (Cmp.isSigned()) { in foldICmpAddConstant()
2916 Instruction *InstCombinerImpl::foldICmpSelectConstant(ICmpInst &Cmp, in foldICmpSelectConstant() argument
2928 if (Cmp.hasOneUse() && in foldICmpSelectConstant()
2934 ConstantExpr::getCompare(Cmp.getPredicate(), C1LessThan, C) in foldICmpSelectConstant()
2937 ConstantExpr::getCompare(Cmp.getPredicate(), C2Equal, C) in foldICmpSelectConstant()
2940 ConstantExpr::getCompare(Cmp.getPredicate(), C3GreaterThan, C) in foldICmpSelectConstant()
2962 return replaceInstUsesWith(Cmp, Cond); in foldICmpSelectConstant()
2967 Instruction *InstCombinerImpl::foldICmpBitCast(ICmpInst &Cmp) { in foldICmpBitCast() argument
2968 auto *Bitcast = dyn_cast<BitCastInst>(Cmp.getOperand(0)); in foldICmpBitCast()
2972 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBitCast()
2973 Value *Op1 = Cmp.getOperand(1); in foldICmpBitCast()
3008 if (Cmp.isEquality() && match(Op1, m_Zero())) in foldICmpBitCast()
3055 if (!match(Cmp.getOperand(1), m_APInt(C)) || !DstType->isIntegerTy() || in foldICmpBitCast()
3066 if (Cmp.isEquality() && C->isAllOnes() && Bitcast->hasOneUse() && in foldICmpBitCast()
3076 if (Cmp.isEquality() && C->isZero() && Bitcast->hasOneUse() && in foldICmpBitCast()
3117 Instruction *InstCombinerImpl::foldICmpInstWithConstant(ICmpInst &Cmp) { in foldICmpInstWithConstant() argument
3120 if (match(Cmp.getOperand(1), m_APInt(C))) { in foldICmpInstWithConstant()
3121 if (auto *BO = dyn_cast<BinaryOperator>(Cmp.getOperand(0))) in foldICmpInstWithConstant()
3122 if (Instruction *I = foldICmpBinOpWithConstant(Cmp, BO, *C)) in foldICmpInstWithConstant()
3125 if (auto *SI = dyn_cast<SelectInst>(Cmp.getOperand(0))) in foldICmpInstWithConstant()
3129 if (auto *ConstRHS = dyn_cast<ConstantInt>(Cmp.getOperand(1))) in foldICmpInstWithConstant()
3130 if (Instruction *I = foldICmpSelectConstant(Cmp, SI, ConstRHS)) in foldICmpInstWithConstant()
3133 if (auto *TI = dyn_cast<TruncInst>(Cmp.getOperand(0))) in foldICmpInstWithConstant()
3134 if (Instruction *I = foldICmpTruncConstant(Cmp, TI, *C)) in foldICmpInstWithConstant()
3137 if (auto *II = dyn_cast<IntrinsicInst>(Cmp.getOperand(0))) in foldICmpInstWithConstant()
3138 if (Instruction *I = foldICmpIntrinsicWithConstant(Cmp, II, *C)) in foldICmpInstWithConstant()
3142 if (match(Cmp.getOperand(1), m_APIntAllowUndef(C))) in foldICmpInstWithConstant()
3143 return foldICmpInstWithConstantAllowUndef(Cmp, *C); in foldICmpInstWithConstant()
3151 ICmpInst &Cmp, BinaryOperator *BO, const APInt &C) { in foldICmpBinOpEqualityWithConstant() argument
3154 if (!Cmp.isEquality()) in foldICmpBinOpEqualityWithConstant()
3157 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBinOpEqualityWithConstant()
3159 Constant *RHS = cast<Constant>(Cmp.getOperand(1)); in foldICmpBinOpEqualityWithConstant()
3243 ICmpInst &Cmp, IntrinsicInst *II, const APInt &C) { in foldICmpEqIntrinsicWithConstant() argument
3246 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpEqIntrinsicWithConstant()
3337 static Instruction *foldICmpIntrinsicWithIntrinsic(ICmpInst &Cmp) { in foldICmpIntrinsicWithIntrinsic() argument
3338 assert(Cmp.isEquality()); in foldICmpIntrinsicWithIntrinsic()
3340 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithIntrinsic()
3341 Value *Op0 = Cmp.getOperand(0); in foldICmpIntrinsicWithIntrinsic()
3342 Value *Op1 = Cmp.getOperand(1); in foldICmpIntrinsicWithIntrinsic()
3376 InstCombinerImpl::foldICmpInstWithConstantAllowUndef(ICmpInst &Cmp, in foldICmpInstWithConstantAllowUndef() argument
3378 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpInstWithConstantAllowUndef()
3379 if (auto *II = dyn_cast<IntrinsicInst>(Cmp.getOperand(0))) { in foldICmpInstWithConstantAllowUndef()
3385 if (Cmp.isEquality() && II->getArgOperand(0) == II->getArgOperand(1)) { in foldICmpInstWithConstantAllowUndef()
3388 return new ICmpInst(Pred, II->getArgOperand(0), Cmp.getOperand(1)); in foldICmpInstWithConstantAllowUndef()
3398 Instruction *InstCombinerImpl::foldICmpBinOpWithConstant(ICmpInst &Cmp, in foldICmpBinOpWithConstant() argument
3403 if (Instruction *I = foldICmpXorConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3407 if (Instruction *I = foldICmpAndConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3411 if (Instruction *I = foldICmpOrConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3415 if (Instruction *I = foldICmpMulConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3419 if (Instruction *I = foldICmpShlConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3424 if (Instruction *I = foldICmpShrConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3428 if (Instruction *I = foldICmpSRemConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3432 if (Instruction *I = foldICmpUDivConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3436 if (Instruction *I = foldICmpDivConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3440 if (Instruction *I = foldICmpSubConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3444 if (Instruction *I = foldICmpAddConstant(Cmp, BO, C)) in foldICmpBinOpWithConstant()
3452 return foldICmpBinOpEqualityWithConstant(Cmp, BO, C); in foldICmpBinOpWithConstant()
3456 Instruction *InstCombinerImpl::foldICmpIntrinsicWithConstant(ICmpInst &Cmp, in foldICmpIntrinsicWithConstant() argument
3459 if (Cmp.isEquality()) in foldICmpIntrinsicWithConstant()
3460 return foldICmpEqIntrinsicWithConstant(Cmp, II, C); in foldICmpIntrinsicWithConstant()
3464 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithConstant()
4505 static Instruction *foldICmpWithMinMax(ICmpInst &Cmp) { in foldICmpWithMinMax() argument
4506 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithMinMax()
4507 Value *Op0 = Cmp.getOperand(0); in foldICmpWithMinMax()
4508 Value *X = Cmp.getOperand(1); in foldICmpWithMinMax()
4516 Pred = Cmp.getSwappedPredicate(); in foldICmpWithMinMax()
5532 auto isMinMaxCmp = [&](Instruction &Cmp) { in foldICmpUsingKnownBits() argument
5533 if (!Cmp.hasOneUse()) in foldICmpUsingKnownBits()
5536 SelectPatternFlavor SPF = matchSelectPattern(Cmp.user_back(), A, B).Flavor; in foldICmpUsingKnownBits()
5939 static Instruction *foldICmpWithHighBitMask(ICmpInst &Cmp, in foldICmpWithHighBitMask() argument
5943 if (match(&Cmp, in foldICmpWithHighBitMask()
5955 } else if (match(&Cmp, m_c_ICmp(Pred, in foldICmpWithHighBitMask()
5982 static Instruction *foldVectorCmp(CmpInst &Cmp, in foldVectorCmp() argument
5984 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldVectorCmp()
5985 Value *LHS = Cmp.getOperand(0), *RHS = Cmp.getOperand(1); in foldVectorCmp()