Lines Matching refs:Pred

81 static bool isSignTest(ICmpInst::Predicate &Pred, const APInt &C) {  in isSignTest()  argument
82 if (!ICmpInst::isSigned(Pred)) in isSignTest()
86 return ICmpInst::isRelational(Pred); in isSignTest()
89 if (Pred == ICmpInst::ICMP_SLT) { in isSignTest()
90 Pred = ICmpInst::ICMP_SLE; in isSignTest()
94 if (Pred == ICmpInst::ICMP_SGT) { in isSignTest()
95 Pred = ICmpInst::ICMP_SGE; in isSignTest()
913 ICmpInst::Predicate Pred) { in foldICmpAddOpConst() argument
922 if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_ULE) { in foldICmpAddOpConst()
931 if (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_UGE) in foldICmpAddOpConst()
943 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) in foldICmpAddOpConst()
954 assert(Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE); in foldICmpAddOpConst()
967 auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { in foldICmpShrConstConst() argument
969 Pred = CmpInst::getInversePredicate(Pred); in foldICmpShrConstConst()
970 return new ICmpInst(Pred, LHS, RHS); in foldICmpShrConstConst()
1026 auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { in foldICmpShlConstConst() argument
1028 Pred = CmpInst::getInversePredicate(Pred); in foldICmpShlConstConst()
1029 return new ICmpInst(Pred, LHS, RHS); in foldICmpShlConstConst()
1156 ICmpInst::Predicate Pred; in foldIRemByPowerOfTwoToBitTest() local
1158 if (!match(&I, m_ICmp(Pred, m_OneUse(m_IRem(m_Value(X), m_Value(Y))), in foldIRemByPowerOfTwoToBitTest()
1166 return ICmpInst::Create(Instruction::ICmp, Pred, Masked, Zero); in foldIRemByPowerOfTwoToBitTest()
1173 ICmpInst::Predicate Pred; in foldSignBitTest() local
1174 if (!I.isEquality() || !match(&I, m_ICmp(Pred, m_Instruction(Val), m_Zero()))) in foldSignBitTest()
1196 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_SGE in foldSignBitTest()
1203 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithZero() local
1208 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpWithZero()
1212 return new ICmpInst(Pred, B, Cmp.getOperand(1)); in foldICmpWithZero()
1214 return new ICmpInst(Pred, A, Cmp.getOperand(1)); in foldICmpWithZero()
1227 ICmpInst::isEquality(Pred)) { in foldICmpWithZero()
1231 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1237 ICmpInst::isEquality(Pred)) { in foldICmpWithZero()
1243 return new ICmpInst(Pred, Y, Cmp.getOperand(1)); in foldICmpWithZero()
1249 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1260 return new ICmpInst(Pred, Y, Cmp.getOperand(1)); in foldICmpWithZero()
1265 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1296 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithConstant() local
1300 if (Pred == ICmpInst::ICMP_UGT && match(Op1, m_ConstantInt(CI)) && in foldICmpWithConstant()
1315 ConstantFoldCompareInstOperands(Pred, cast<Constant>(V), C, DL); in foldICmpWithConstant()
1322 for (auto [V, Pred] : zip(Ops, Phi->blocks())) in foldICmpWithConstant()
1323 NewPhi->addIncoming(V, Pred); in foldICmpWithConstant()
1342 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithDominatingICmp() local
1343 ConstantRange CR = ConstantRange::makeExactICmpRegion(Pred, *C); in foldICmpWithDominatingICmp()
1369 bool IsSignBit = isSignBitCheck(Pred, *C, UnusedBit); in foldICmpWithDominatingICmp()
1413 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpTruncConstant() local
1423 return new ICmpInst(Pred, X, ConstantInt::get(SrcTy, C.sext(SrcBits))); in foldICmpTruncConstant()
1425 return new ICmpInst(Pred, X, ConstantInt::get(SrcTy, C.zext(SrcBits))); in foldICmpTruncConstant()
1431 if (Pred == ICmpInst::ICMP_SLT && match(X, m_Signum(m_Value(V)))) in foldICmpTruncConstant()
1443 auto NewPred = (Pred == Cmp.ICMP_EQ) ? Cmp.ICMP_UGE : Cmp.ICMP_ULT; in foldICmpTruncConstant()
1449 return new ICmpInst(Pred, Y, ConstantInt::get(SrcTy, C.logBase2())); in foldICmpTruncConstant()
1460 return new ICmpInst(Pred, And, WideC); in foldICmpTruncConstant()
1472 return new ICmpInst(Pred, X, ConstantInt::get(SrcTy, NewRHS)); in foldICmpTruncConstant()
1482 if (isSignBitCheck(Pred, C, TrueIfSigned) && in foldICmpTruncConstant()
1500 ICmpInst::Predicate Pred; in foldICmpTruncWithTruncOrExt() local
1503 if (match(&Cmp, m_ICmp(Pred, m_Trunc(m_Value(X)), m_Trunc(m_Value(Y))))) { in foldICmpTruncWithTruncOrExt()
1523 Pred = Cmp.getSwappedPredicate(Pred); in foldICmpTruncWithTruncOrExt()
1529 match(&Cmp, m_c_ICmp(Pred, m_NUWTrunc(m_Value(X)), in foldICmpTruncWithTruncOrExt()
1534 else if (match(&Cmp, m_c_ICmp(Pred, m_NSWTrunc(m_Value(X)), in foldICmpTruncWithTruncOrExt()
1552 return new ICmpInst(Pred, X, NewY); in foldICmpTruncWithTruncOrExt()
1570 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpXorConstant() local
1591 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1592 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1597 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1598 Pred = Cmp.getSwappedPredicate(Pred); in foldICmpXorConstant()
1599 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1604 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpXorConstant()
1612 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpXorConstant()
1631 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpXorShiftConst() local
1633 if (Pred == ICmpInst::ICMP_ULT) in foldICmpXorShiftConst()
1635 else if (Pred == ICmpInst::ICMP_UGT && !C.isMaxValue()) in foldICmpXorShiftConst()
1652 Pred == ICmpInst::ICMP_ULT ? PowerOf2 << 1 : ((PowerOf2 << 1) - 1); in foldICmpXorShiftConst()
1653 return new ICmpInst(Pred, Add, ConstantInt::get(XType, Bound)); in foldICmpXorShiftConst()
1879 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAndConstant() local
1881 if (isSignBitCheck(Pred, C, TrueIfNeg)) { in foldICmpAndConstant()
1922 Pred == CmpInst::ICMP_EQ ? CmpInst::ICMP_UGT : CmpInst::ICMP_ULE; in foldICmpAndConstant()
1935 if (C.isZero() && (Pred == CmpInst::ICMP_EQ || And->hasOneUse())) { in foldICmpAndConstant()
1944 if (Pred == CmpInst::ICMP_NE) in foldICmpAndConstant()
1957 if (C.isZero() ^ (Pred == CmpInst::ICMP_NE)) { in foldICmpAndConstant()
1972 return new ICmpInst(Pred, LShr, Constant::getNullValue(LShr->getType())); in foldICmpAndConstant()
2024 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpOrXorSubChain() local
2025 auto BOpc = Pred == CmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpOrXorSubChain()
2026 Value *LhsCmp = Builder.CreateICmp(Pred, CmpValues.rbegin()->first, in foldICmpOrXorSubChain()
2030 Value *RhsCmp = Builder.CreateICmp(Pred, It->first, It->second); in foldICmpOrXorSubChain()
2041 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpOrConstant() local
2045 if (Pred == ICmpInst::ICMP_SLT && match(Or, m_Signum(m_Value(V)))) in foldICmpOrConstant()
2058 return new ICmpInst(Pred, OrOp0, NewC); in foldICmpOrConstant()
2067 Pred = (Pred == CmpInst::ICMP_EQ) ? CmpInst::ICMP_ULE : CmpInst::ICMP_UGT; in foldICmpOrConstant()
2068 return new ICmpInst(Pred, OrOp0, OrOp1); in foldICmpOrConstant()
2078 return new ICmpInst(Pred, And, NewC); in foldICmpOrConstant()
2086 if (isSignBitCheck(Pred, C, TrueIfSigned) && in foldICmpOrConstant()
2096 switch (Pred) { in foldICmpOrConstant()
2102 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpOrConstant()
2109 return new ICmpInst(ICmpInst::getFlippedStrictnessPredicate(Pred), X, in foldICmpOrConstant()
2125 Builder.CreateICmp(Pred, P, ConstantInt::getNullValue(P->getType())); in foldICmpOrConstant()
2127 Builder.CreateICmp(Pred, Q, ConstantInt::getNullValue(Q->getType())); in foldICmpOrConstant()
2128 auto BOpc = Pred == CmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpOrConstant()
2142 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpMulConstant() local
2151 return new ICmpInst(Pred, X, ConstantInt::getNullValue(MulTy)); in foldICmpMulConstant()
2161 if (isSignTest(Pred, C) && Mul->hasNoSignedWrap()) { in foldICmpMulConstant()
2163 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpMulConstant()
2164 return new ICmpInst(Pred, X, ConstantInt::getNullValue(MulTy)); in foldICmpMulConstant()
2176 return new ICmpInst(Pred, X, NewC); in foldICmpMulConstant()
2188 return new ICmpInst(Pred, X, NewC); in foldICmpMulConstant()
2198 if (Mul->hasNoSignedWrap() && ICmpInst::isSigned(Pred)) { in foldICmpMulConstant()
2203 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpMulConstant()
2205 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SGE) { in foldICmpMulConstant()
2209 assert((Pred == ICmpInst::ICMP_SLE || Pred == ICmpInst::ICMP_SGT) && in foldICmpMulConstant()
2214 } else if (Mul->hasNoUnsignedWrap() && ICmpInst::isUnsigned(Pred)) { in foldICmpMulConstant()
2215 if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE) { in foldICmpMulConstant()
2219 assert((Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT) && in foldICmpMulConstant()
2226 return NewC ? new ICmpInst(Pred, X, NewC) : nullptr; in foldICmpMulConstant()
2239 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlOne() local
2247 if (Pred == ICmpInst::ICMP_ULT) in foldICmpShlOne()
2248 Pred = ICmpInst::ICMP_ULE; in foldICmpShlOne()
2249 else if (Pred == ICmpInst::ICMP_UGE) in foldICmpShlOne()
2250 Pred = ICmpInst::ICMP_UGT; in foldICmpShlOne()
2254 return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, CLog2)); in foldICmpShlOne()
2259 if (Pred == ICmpInst::ICMP_SGT && C.sle(0)) in foldICmpShlOne()
2266 if (Pred == ICmpInst::ICMP_SLT && (C-1).sle(0)) in foldICmpShlOne()
2281 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlConstant() local
2288 return new ICmpInst(Pred, Shl->getOperand(0), Cmp.getOperand(1)); in foldICmpShlConstant()
2292 if (ICmpInst::isEquality(Pred) && C.isZero() && in foldICmpShlConstant()
2294 return new ICmpInst(Pred, Shl->getOperand(0), Cmp.getOperand(1)); in foldICmpShlConstant()
2303 (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT)) in foldICmpShlConstant()
2304 if (C.isZero() || (Pred == ICmpInst::ICMP_SGT ? C.isAllOnes() : C.isOne())) in foldICmpShlConstant()
2305 return new ICmpInst(Pred, Shl->getOperand(0), Cmp.getOperand(1)); in foldICmpShlConstant()
2324 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpShlConstant()
2327 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2329 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2332 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2334 if (Pred == ICmpInst::ICMP_SLT) { in foldICmpShlConstant()
2341 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2349 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpShlConstant()
2352 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2354 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2357 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2359 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpShlConstant()
2366 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2377 return new ICmpInst(Pred, And, LShrC); in foldICmpShlConstant()
2382 if (Shl->hasOneUse() && isSignBitCheck(Pred, C, TrueIfSigned)) { in foldICmpShlConstant()
2396 (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT)) { in foldICmpShlConstant()
2398 return new ICmpInst(Pred == ICmpInst::ICMP_ULE ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2404 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) { in foldICmpShlConstant()
2407 return new ICmpInst(Pred == ICmpInst::ICMP_ULT ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2422 ICmpInst::Predicate CmpPred = Pred; in foldICmpShlConstant()
2434 Pred, ConstantInt::get(ShType->getContext(), C))) { in foldICmpShlConstant()
2461 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShrConstant() local
2463 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpShrConstant()
2475 isSignBitCheck(Pred, C, TrueIfSigned)) in foldICmpShrConstant()
2484 (Pred == CmpInst::ICMP_UGT || Pred == CmpInst::ICMP_ULT)) { in foldICmpShrConstant()
2485 bool IsUGT = Pred == CmpInst::ICMP_UGT; in foldICmpShrConstant()
2515 if (IsExact && (Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_ULT) && in foldICmpShrConstant()
2523 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2525 if (IsExact || Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_ULT) { in foldICmpShrConstant()
2531 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2533 if (Pred == CmpInst::ICMP_SGT) { in foldICmpShrConstant()
2538 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2540 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2547 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2555 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2559 if (Pred == CmpInst::ICMP_ULT) { in foldICmpShrConstant()
2565 if (Pred == CmpInst::ICMP_ULT || (Pred == CmpInst::ICMP_UGT && IsExact)) { in foldICmpShrConstant()
2570 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2572 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2576 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2595 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2599 if (Pred == CmpInst::ICMP_EQ) in foldICmpShrConstant()
2613 return new ICmpInst(Pred, And, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2625 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSRemConstant() local
2626 if (Pred != ICmpInst::ICMP_SGT && Pred != ICmpInst::ICMP_SLT && in foldICmpSRemConstant()
2627 Pred != ICmpInst::ICMP_EQ && Pred != ICmpInst::ICMP_NE) in foldICmpSRemConstant()
2642 if (((Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT) && in foldICmpSRemConstant()
2644 ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpSRemConstant()
2654 if (Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) in foldICmpSRemConstant()
2655 return new ICmpInst(Pred, And, ConstantInt::get(Ty, C)); in foldICmpSRemConstant()
2660 if (Pred == ICmpInst::ICMP_SGT) in foldICmpSRemConstant()
2673 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpUDivConstant() local
2685 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpUDivConstant()
2693 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpUDivConstant()
2706 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpDivConstant() local
2722 Value *XBig = Builder.CreateICmp(Pred, X, ConstantInt::get(Ty, C)); in foldICmpDivConstant()
2723 Value *YOne = Builder.CreateICmp(Pred, Y, ConstantInt::get(Ty, 1)); in foldICmpDivConstant()
2724 auto Logic = Pred == ICmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpDivConstant()
2835 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpDivConstant()
2838 switch (Pred) { in foldICmpDivConstant()
2869 return new ICmpInst(Pred, X, ConstantInt::get(Ty, LoBound)); in foldICmpDivConstant()
2876 if (Pred == ICmpInst::ICMP_UGT) in foldICmpDivConstant()
2889 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSubConstant() local
2896 return new ICmpInst(Pred, Y, in foldICmpSubConstant()
2919 return new ICmpInst(Pred, X, Y); in foldICmpSubConstant()
2931 if (Pred == ICmpInst::ICMP_SGT && C.isAllOnes()) in foldICmpSubConstant()
2935 if (Pred == ICmpInst::ICMP_SGT && C.isZero()) in foldICmpSubConstant()
2939 if (Pred == ICmpInst::ICMP_SLT && C.isZero()) in foldICmpSubConstant()
2943 if (Pred == ICmpInst::ICMP_SLT && C.isOne()) in foldICmpSubConstant()
2952 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && in foldICmpSubConstant()
2958 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == C) in foldICmpSubConstant()
3028 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAddConstant() local
3043 return ICmpInst::compare(APInt(BW, Res, true), C, Pred); in foldICmpAddConstant()
3065 (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT)) || in foldICmpAddConstant()
3067 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULT))) { in foldICmpAddConstant()
3076 return new ICmpInst(Pred, X, ConstantInt::get(Ty, NewC)); in foldICmpAddConstant()
3079 auto CR = ConstantRange::makeExactICmpRegion(Pred, C).subtract(*C2); in foldICmpAddConstant()
3101 if (Pred == CmpInst::ICMP_UGT && C == *C2 + SMax) in foldICmpAddConstant()
3105 if (Pred == CmpInst::ICMP_ULT && C == *C2 + SMin) in foldICmpAddConstant()
3109 if (Pred == CmpInst::ICMP_SGT && C == *C2 - 1) in foldICmpAddConstant()
3113 if (Pred == CmpInst::ICMP_SLT && C == *C2) in foldICmpAddConstant()
3117 if (Pred == CmpInst::ICMP_ULT && C2->isAllOnes()) { in foldICmpAddConstant()
3129 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && (*C2 & (C - 1)) == 0) in foldICmpAddConstant()
3136 if (Pred == ICmpInst::ICMP_ULT && C2->isPowerOf2() && C == -*C2) in foldICmpAddConstant()
3143 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == 0) in foldICmpAddConstant()
3150 if (Pred == ICmpInst::ICMP_UGT) in foldICmpAddConstant()
3265 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBitCast() local
3282 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_SLT || in foldICmpBitCast()
3283 Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT) && in foldICmpBitCast()
3285 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
3288 if (Pred == ICmpInst::ICMP_SLT && match(Op1, m_One())) in foldICmpBitCast()
3289 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), 1)); in foldICmpBitCast()
3292 if (Pred == ICmpInst::ICMP_SGT && match(Op1, m_AllOnes())) in foldICmpBitCast()
3293 return new ICmpInst(Pred, X, in foldICmpBitCast()
3302 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
3311 if (isSignBitCheck(Pred, *C, TrueIfSigned) && in foldICmpBitCast()
3340 if (Pred == ICmpInst::ICMP_NE) in foldICmpBitCast()
3365 return new ICmpInst(Pred, Cast, ConstantInt::getNullValue(DstType)); in foldICmpBitCast()
3378 return new ICmpInst(Pred, NewCast, ConstantInt::getNullValue(NewType)); in foldICmpBitCast()
3405 return new ICmpInst(Pred, Extract, NewC); in foldICmpBitCast()
3468 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBinOpEqualityWithConstant() local
3469 bool isICMP_NE = Pred == ICmpInst::ICMP_NE; in foldICmpBinOpEqualityWithConstant()
3480 return new ICmpInst(Pred, NewRem, in foldICmpBinOpEqualityWithConstant()
3491 return new ICmpInst(Pred, BOp0, ConstantExpr::getSub(RHS, C2)); in foldICmpBinOpEqualityWithConstant()
3496 return new ICmpInst(Pred, BOp0, NegVal); in foldICmpBinOpEqualityWithConstant()
3498 return new ICmpInst(Pred, NegVal, BOp1); in foldICmpBinOpEqualityWithConstant()
3503 return new ICmpInst(Pred, Or, Constant::getNullValue(BO->getType())); in foldICmpBinOpEqualityWithConstant()
3507 return new ICmpInst(Pred, BOp0, Neg); in foldICmpBinOpEqualityWithConstant()
3516 return new ICmpInst(Pred, BOp0, ConstantExpr::getXor(RHS, BOC)); in foldICmpBinOpEqualityWithConstant()
3519 return new ICmpInst(Pred, BOp0, BOp1); in foldICmpBinOpEqualityWithConstant()
3530 return new ICmpInst(Pred, And, NotBOC); in foldICmpBinOpEqualityWithConstant()
3543 return new ICmpInst(Pred, BOp0, Constant::getNullValue(BO->getType())); in foldICmpBinOpEqualityWithConstant()
3545 return new ICmpInst(Pred, BOp0, BOp1); in foldICmpBinOpEqualityWithConstant()
3553 return new ICmpInst(Pred, YC, BOp0); in foldICmpBinOpEqualityWithConstant()
3586 const ICmpInst::Predicate Pred = I.getPredicate(); in foldCtpopPow2Test() local
3587 if (((I.isEquality() || Pred == ICmpInst::ICMP_UGT) && CRhs == 1) || in foldCtpopPow2Test()
3588 (Pred == ICmpInst::ICMP_ULT && CRhs == 2)) { in foldCtpopPow2Test()
3597 (Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_ULT) in foldCtpopPow2Test()
3612 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpEqIntrinsicWithConstant() local
3619 return new ICmpInst(Pred, II->getArgOperand(0), ConstantInt::get(Ty, C)); in foldICmpEqIntrinsicWithConstant()
3624 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3629 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3636 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3650 return new ICmpInst(Pred, Builder.CreateAnd(II->getArgOperand(0), Mask1), in foldICmpEqIntrinsicWithConstant()
3661 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3675 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3688 return new ICmpInst(Pred, Or, Constant::getNullValue(Ty)); in foldICmpEqIntrinsicWithConstant()
3696 return new ICmpInst(Pred, II->getArgOperand(0), II->getArgOperand(1)); in foldICmpEqIntrinsicWithConstant()
3702 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_UGT; in foldICmpEqIntrinsicWithConstant()
3720 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithIntrinsic() local
3733 return new ICmpInst(Pred, IIOp0->getOperand(0), IIOp1->getOperand(0)); in foldICmpIntrinsicWithIntrinsic()
3743 return new ICmpInst(Pred, IIOp0->getOperand(0), IIOp1->getOperand(0)); in foldICmpIntrinsicWithIntrinsic()
3758 return new ICmpInst(Pred, IIOp1->getOperand(0), CombinedRotate); in foldICmpIntrinsicWithIntrinsic()
3774 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpInstWithConstantAllowPoison() local
3784 return new ICmpInst(Pred, II->getArgOperand(0), Cmp.getOperand(1)); in foldICmpInstWithConstantAllowPoison()
3852 foldICmpUSubSatOrUAddSatWithConstant(ICmpInst::Predicate Pred, in foldICmpUSubSatOrUAddSatWithConstant() argument
3896 bool SatValCheck = ICmpInst::compare(SatVal, C, Pred); in foldICmpUSubSatOrUAddSatWithConstant()
3906 ConstantRange C2 = ConstantRange::makeExactICmpRegion(Pred, C); in foldICmpUSubSatOrUAddSatWithConstant()
3937 foldICmpOfCmpIntrinsicWithConstant(ICmpInst::Predicate Pred, IntrinsicInst *I, in foldICmpOfCmpIntrinsicWithConstant() argument
3941 switch (Pred) { in foldICmpOfCmpIntrinsicWithConstant()
3945 NewPredicate = Pred; in foldICmpOfCmpIntrinsicWithConstant()
3948 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_ULE; in foldICmpOfCmpIntrinsicWithConstant()
3951 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_ULT : ICmpInst::ICMP_UGE; in foldICmpOfCmpIntrinsicWithConstant()
3986 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithConstant() local
3995 Pred, cast<SaturatingInst>(II), C, Builder)) in foldICmpIntrinsicWithConstant()
4005 if (auto *Folded = foldICmpOfCmpIntrinsicWithConstant(Pred, II, C, Builder)) in foldICmpIntrinsicWithConstant()
4019 if (C == BitWidth - 1 && Pred == ICmpInst::ICMP_UGT) in foldICmpIntrinsicWithConstant()
4023 if (C == BitWidth && Pred == ICmpInst::ICMP_ULT) in foldICmpIntrinsicWithConstant()
4030 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
4038 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
4052 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
4060 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
4070 if (ICmpInst::isSigned(Pred)) { in foldICmpIntrinsicWithConstant()
4072 return new ICmpInst(Pred, II->getArgOperand(0), II->getArgOperand(1)); in foldICmpIntrinsicWithConstant()
4074 if (Pred == ICmpInst::ICMP_SLT && C.isOne()) in foldICmpIntrinsicWithConstant()
4078 if (Pred == ICmpInst::ICMP_SGT && C.isAllOnes()) in foldICmpIntrinsicWithConstant()
4126 Instruction *InstCombinerImpl::foldSelectICmp(ICmpInst::Predicate Pred, in foldSelectICmp() argument
4132 if (Value *Res = simplifyICmpInst(Pred, Op, RHS, SQ)) in foldSelectICmp()
4135 SI->getCondition(), Pred, Op, RHS, DL, SelectCondIsTrue)) in foldSelectICmp()
4172 Op1 = Builder.CreateICmp(Pred, SI->getOperand(1), RHS, I.getName()); in foldSelectICmp()
4174 Op2 = Builder.CreateICmp(Pred, SI->getOperand(2), RHS, I.getName()); in foldSelectICmp()
4289 static Value *foldICmpWithLowBitMaskedVal(ICmpInst::Predicate Pred, Value *Op0, in foldICmpWithLowBitMaskedVal() argument
4294 switch (Pred) { in foldICmpWithLowBitMaskedVal()
4354 return !ICmpInst::isSigned(Pred) || in foldICmpWithLowBitMaskedVal()
4360 return !ICmpInst::isSigned(Pred) || isKnownNonZero(X, Q); in foldICmpWithLowBitMaskedVal()
4364 if (ICmpInst::isEquality(Pred) && match(Op1, m_AllOnes()) && in foldICmpWithLowBitMaskedVal()
4383 if (ICmpInst::isEquality(Pred) && match(Op1, m_Zero()) && in foldICmpWithLowBitMaskedVal()
4667 ICmpInst::Predicate Pred; in foldMultiplicationOverflowCheck() local
4674 match(&I, m_c_ICmp(Pred, in foldMultiplicationOverflowCheck()
4681 switch (Pred) { in foldMultiplicationOverflowCheck()
4694 m_c_ICmp(Pred, m_Value(Y), in foldMultiplicationOverflowCheck()
4701 NeedNegation = Pred == ICmpInst::Predicate::ICMP_EQ; in foldMultiplicationOverflowCheck()
4739 CmpInst::Predicate Pred; in foldICmpXNegX() local
4741 if (match(&I, m_c_ICmp(Pred, m_NSWNeg(m_Value(X)), m_Deferred(X)))) { in foldICmpXNegX()
4743 if (ICmpInst::isSigned(Pred)) in foldICmpXNegX()
4744 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpXNegX()
4745 else if (ICmpInst::isUnsigned(Pred)) in foldICmpXNegX()
4746 Pred = ICmpInst::getSignedPredicate(Pred); in foldICmpXNegX()
4749 return ICmpInst::Create(Instruction::ICmp, Pred, X, in foldICmpXNegX()
4755 if (match(&I, m_c_ICmp(Pred, m_OneUse(m_Neg(m_Value(X))), m_Deferred(X))) && in foldICmpXNegX()
4756 ICmpInst::isEquality(Pred)) { in foldICmpXNegX()
4763 return CmpInst::Create(Instruction::ICmp, Pred, And, Zero); in foldICmpXNegX()
4773 CmpInst::Predicate Pred = I.getPredicate(); in foldICmpAndXX() local
4776 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpAndXX()
4783 if (Pred == ICmpInst::ICMP_ULT) in foldICmpAndXX()
4787 if (Pred == ICmpInst::ICMP_UGE) in foldICmpAndXX()
4790 if (ICmpInst::isEquality(Pred) && Op0->hasOneUse()) { in foldICmpAndXX()
4797 return new ICmpInst(Pred, IC.Builder.CreateOr(A, NotOp1), in foldICmpAndXX()
4801 return new ICmpInst(Pred, IC.Builder.CreateAnd(Op1, NotA), in foldICmpAndXX()
4805 if (!ICmpInst::isSigned(Pred)) in foldICmpAndXX()
4811 return new ICmpInst(ICmpInst::getUnsignedPredicate(Pred), Op0, Op1); in foldICmpAndXX()
4813 if (Pred != ICmpInst::ICMP_SLE && Pred != ICmpInst::ICMP_SGT) in foldICmpAndXX()
4819 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1, in foldICmpAndXX()
4825 return new ICmpInst(ICmpInst::getFlippedStrictnessPredicate(Pred), A, in foldICmpAndXX()
4836 CmpInst::Predicate Pred = I.getPredicate(); in foldICmpOrXX() local
4839 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpOrXX()
4845 if (Pred == ICmpInst::ICMP_ULE) in foldICmpOrXX()
4849 if (Pred == ICmpInst::ICMP_UGT) in foldICmpOrXX()
4852 if (ICmpInst::isEquality(Pred) && Op0->hasOneUse()) { in foldICmpOrXX()
4856 return new ICmpInst(Pred, IC.Builder.CreateAnd(A, NotOp1), in foldICmpOrXX()
4860 return new ICmpInst(Pred, IC.Builder.CreateOr(Op1, NotA), in foldICmpOrXX()
4870 CmpInst::Predicate Pred = I.getPredicate(); in foldICmpXorXX() local
4873 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpXorXX()
4882 CmpInst::Predicate PredOut = CmpInst::getStrictPredicate(Pred); in foldICmpXorXX()
4883 if (PredOut != Pred && isKnownNonZero(A, Q)) in foldICmpXorXX()
4907 const CmpInst::Predicate Pred = I.getPredicate(); in foldICmpBinOp() local
4913 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
4914 return new ICmpInst(Pred, Builder.CreateNot(Op1), X); in foldICmpBinOp()
4917 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
4918 return new ICmpInst(Pred, X, Builder.CreateNot(Op0)); in foldICmpBinOp()
4925 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) { in foldICmpBinOp()
4927 return new ICmpInst(Pred, Builder.CreateSub(C2, X), Op1); in foldICmpBinOp()
4932 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) { in foldICmpBinOp()
4934 return new ICmpInst(Pred, Op0, Builder.CreateSub(C2, X)); in foldICmpBinOp()
4946 if ((Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE) && in foldICmpBinOp()
4950 Pred == ICmpInst::ICMP_ULT ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ; in foldICmpBinOp()
4955 if ((Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE) && in foldICmpBinOp()
4959 Pred == ICmpInst::ICMP_UGT ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ; in foldICmpBinOp()
4970 auto hasNoWrapProblem = [](const BinaryOperator &BO, CmpInst::Predicate Pred, in foldICmpBinOp()
4975 return ICmpInst::isEquality(Pred) || in foldICmpBinOp()
4976 (CmpInst::isUnsigned(Pred) && HasNUW) || in foldICmpBinOp()
4977 (CmpInst::isSigned(Pred) && HasNSW); in foldICmpBinOp()
4990 NoOp0WrapProblem = hasNoWrapProblem(*BO0, Pred, Op0HasNSW, Op0HasNUW); in foldICmpBinOp()
4994 NoOp1WrapProblem = hasNoWrapProblem(*BO1, Pred, Op1HasNSW, Op1HasNUW); in foldICmpBinOp()
5000 return new ICmpInst(Pred, A == Op1 ? B : A, in foldICmpBinOp()
5006 return new ICmpInst(Pred, Constant::getNullValue(Op0->getType()), in foldICmpBinOp()
5032 return new ICmpInst(Pred, Y, Z); in foldICmpBinOp()
5036 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SLT && in foldICmpBinOp()
5041 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SGE && in foldICmpBinOp()
5046 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SLE && match(B, m_One())) in foldICmpBinOp()
5050 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SGT && match(B, m_One())) in foldICmpBinOp()
5054 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SGT && in foldICmpBinOp()
5059 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SLE && in foldICmpBinOp()
5064 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SGE && match(D, m_One())) in foldICmpBinOp()
5068 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SLT && match(D, m_One())) in foldICmpBinOp()
5081 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_ULE && match(B, m_One())) in foldICmpBinOp()
5085 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_UGT && match(B, m_One())) in foldICmpBinOp()
5089 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_UGE && match(D, m_One())) in foldICmpBinOp()
5093 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_ULT && match(D, m_One())) in foldICmpBinOp()
5118 return new ICmpInst(Pred, NewAdd, C); in foldICmpBinOp()
5124 return new ICmpInst(Pred, A, NewAdd); in foldICmpBinOp()
5129 ICmpInst::isEquality(Pred)) { in foldICmpBinOp()
5132 return new ICmpInst(Pred, A, NewAdd); in foldICmpBinOp()
5153 return new ICmpInst(Pred, Constant::getNullValue(Op1->getType()), B); in foldICmpBinOp()
5156 return new ICmpInst(Pred, D, Constant::getNullValue(Op0->getType())); in foldICmpBinOp()
5160 if (A == Op1 && (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
5161 return new ICmpInst(Pred, B, A); in foldICmpBinOp()
5163 if (C == Op0 && (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
5164 return new ICmpInst(Pred, C, D); in foldICmpBinOp()
5166 if (A == Op1 && (Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_ULT) && in foldICmpBinOp()
5168 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), B, A); in foldICmpBinOp()
5170 if (C == Op0 && (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT) && in foldICmpBinOp()
5172 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), C, D); in foldICmpBinOp()
5176 return new ICmpInst(Pred, A, C); in foldICmpBinOp()
5180 return new ICmpInst(Pred, D, B); in foldICmpBinOp()
5183 if (NoOp0WrapProblem && ICmpInst::isSigned(Pred)) { in foldICmpBinOp()
5201 if (Pred == ICmpInst::getUnsignedPredicate(Pred) && in foldICmpBinOp()
5207 if (ICmpInst::isEquality(Pred)) { in foldICmpBinOp()
5212 return new ICmpInst(Pred, X, Y); in foldICmpBinOp()
5217 return new ICmpInst(Pred, X, Y); in foldICmpBinOp()
5224 return new ICmpInst(Pred, X, Y); in foldICmpBinOp()
5239 switch (SRem == BO0 ? ICmpInst::getSwappedPredicate(Pred) : Pred) { in foldICmpBinOp()
5267 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
5301 return new ICmpInst(Pred, And1, And2); in foldICmpBinOp()
5310 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
5316 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
5321 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
5330 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
5340 if (match(BO0, BitwiseAnd) && Pred == ICmpInst::ICMP_ULT) { in foldICmpBinOp()
5349 if (!ICmpInst::isSigned(Pred)) { in foldICmpBinOp()
5351 return new ICmpInst(ICmpInst::getSignedPredicate(Pred), Op1, in foldICmpBinOp()
5354 return new ICmpInst(ICmpInst::getSignedPredicate(Pred), in foldICmpBinOp()
5377 ICmpInst::Predicate Pred) { in foldICmpWithMinMax() argument
5380 if (ICmpInst::isSigned(Pred) && !MinMax->isSigned()) in foldICmpWithMinMax()
5382 if (ICmpInst::isUnsigned(Pred) && MinMax->isSigned()) { in foldICmpWithMinMax()
5388 Pred = ICmpInst::getFlippedSignednessPredicate(Pred); in foldICmpWithMinMax()
5402 auto CmpXZ = IsCondKnownTrue(simplifyICmpInst(Pred, X, Z, Q)); in foldICmpWithMinMax()
5403 auto CmpYZ = IsCondKnownTrue(simplifyICmpInst(Pred, Y, Z, Q)); in foldICmpWithMinMax()
5414 return ICmpInst::Create(Instruction::ICmp, Pred, Y, Z); in foldICmpWithMinMax()
5417 switch (Pred) { in foldICmpWithMinMax()
5426 if ((Pred == ICmpInst::ICMP_EQ) == *CmpXZ) { in foldICmpWithMinMax()
5429 if (Pred == ICmpInst::ICMP_NE) in foldICmpWithMinMax()
5440 if (!CmpXZ.has_value() || (Pred == ICmpInst::ICMP_EQ) == *CmpXZ) in foldICmpWithMinMax()
5453 I, ConstantInt::getBool(I.getType(), Pred == ICmpInst::ICMP_NE)); in foldICmpWithMinMax()
5472 bool IsSame = MinMax->getPredicate() == ICmpInst::getStrictPredicate(Pred); in foldICmpWithMinMax()
5519 const CmpInst::Predicate Pred = I.getPredicate(); in foldICmpPow2Test() local
5538 CheckIs = Pred == ICmpInst::ICMP_EQ; in foldICmpPow2Test()
5539 } else if (ICmpInst::isUnsigned(Pred)) { in foldICmpPow2Test()
5543 if ((Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_ULT) && in foldICmpPow2Test()
5547 CheckIs = Pred == ICmpInst::ICMP_UGE; in foldICmpPow2Test()
5548 } else if ((Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE) && in foldICmpPow2Test()
5552 CheckIs = Pred == ICmpInst::ICMP_ULE; in foldICmpPow2Test()
5573 const CmpInst::Predicate Pred = I.getPredicate(); in foldICmpEquality() local
5578 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
5588 return new ICmpInst(Pred, A, Xor); in foldICmpEquality()
5593 return new ICmpInst(Pred, B, D); in foldICmpEquality()
5595 return new ICmpInst(Pred, B, C); in foldICmpEquality()
5597 return new ICmpInst(Pred, A, D); in foldICmpEquality()
5599 return new ICmpInst(Pred, A, C); in foldICmpEquality()
5606 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
5650 return new ICmpInst(Pred, Op1, Constant::getNullValue(Op1->getType())); in foldICmpEquality()
5664 return new ICmpInst(Pred, And, Constant::getNullValue(And->getType())); in foldICmpEquality()
5675 return new ICmpInst(Pred, A, Builder.CreateTrunc(B, A->getType())); in foldICmpEquality()
5691 Pred == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT; in foldICmpEquality()
5709 return new ICmpInst(Pred, And, Constant::getNullValue(Cst1->getType())); in foldICmpEquality()
5733 return new ICmpInst(Pred, Mask, Builder.getInt(CmpV)); in foldICmpEquality()
5751 return new ICmpInst(Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_ULT in foldICmpEquality()
5762 return new ICmpInst(CmpInst::getInversePredicate(Pred), Op0, in foldICmpEquality()
5767 return new ICmpInst(CmpInst::getInversePredicate(Pred), Op1, in foldICmpEquality()
5775 CmpInst::Predicate PredUnused = Pred; in foldICmpEquality()
5780 Pred, A, in foldICmpEquality()
5789 return new ICmpInst(Pred, Builder.CreateXor(A, B), Cst); in foldICmpEquality()
5812 return new ICmpInst(Pred, Builder.CreateAnd(B, A), in foldICmpEquality()
5821 ICmpInst::Predicate Pred = ICmp.getPredicate(); in foldICmpWithTrunc() local
5835 if (decomposeBitTestICmp(Op0, Op1, Pred, X, Mask, true /* WithTrunc */)) { in foldICmpWithTrunc()
5838 return new ICmpInst(Pred, And, Zero); in foldICmpWithTrunc()
5842 if (Pred == ICmpInst::ICMP_ULT && C->isNegatedPowerOf2()) { in foldICmpWithTrunc()
5850 if (Pred == ICmpInst::ICMP_UGT && (~*C).isPowerOf2()) { in foldICmpWithTrunc()
6437 ICmpInst::Predicate Pred = I.getPredicate(); in foldICmpUsingKnownBits() local
6485 return new ICmpInst(Pred, ConstantExpr::getIntegerValue(Ty, Op0Min), Op1); in foldICmpUsingKnownBits()
6487 return new ICmpInst(Pred, Op0, ConstantExpr::getIntegerValue(Ty, Op1Min)); in foldICmpUsingKnownBits()
6504 switch (Pred) { in foldICmpUsingKnownBits()
6568 switch (Pred) { in foldICmpUsingKnownBits()
6575 I, ConstantInt::getBool(I.getType(), Pred == CmpInst::ICMP_NE)); in foldICmpUsingKnownBits()
6603 Pred == CmpInst::ICMP_EQ ? CmpInst::ICMP_UGE : CmpInst::ICMP_ULT; in foldICmpUsingKnownBits()
6612 return new ICmpInst(CmpInst::getInversePredicate(Pred), Op0, in foldICmpUsingKnownBits()
6696 ICmpInst::Predicate Pred; in foldICmpUsingBoolRange() local
6700 if (match(&I, m_c_ICmp(Pred, m_Value(X), m_OneUse(m_ZExt(m_Value(Y))))) && in foldICmpUsingBoolRange()
6701 Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULT) in foldICmpUsingBoolRange()
6706 if (match(&I, m_c_ICmp(Pred, m_Value(X), m_OneUse(m_SExt(m_Value(Y))))) && in foldICmpUsingBoolRange()
6707 Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) in foldICmpUsingBoolRange()
6781 InstCombiner::getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred, in getFlippedStrictnessPredicateAndConstant() argument
6783 assert(ICmpInst::isRelational(Pred) && ICmpInst::isIntPredicate(Pred) && in getFlippedStrictnessPredicateAndConstant()
6787 bool IsSigned = ICmpInst::isSigned(Pred); in getFlippedStrictnessPredicateAndConstant()
6789 CmpInst::Predicate UnsignedPred = ICmpInst::getUnsignedPredicate(Pred); in getFlippedStrictnessPredicateAndConstant()
6844 CmpInst::Predicate NewPred = CmpInst::getFlippedStrictnessPredicate(Pred); in getFlippedStrictnessPredicateAndConstant()
6857 ICmpInst::Predicate Pred = I.getPredicate(); in canonicalizeCmpWithConstant() local
6858 if (ICmpInst::isEquality(Pred) || !ICmpInst::isIntPredicate(Pred) || in canonicalizeCmpWithConstant()
6859 InstCombiner::isCanonicalPredicate(Pred)) in canonicalizeCmpWithConstant()
6869 InstCombiner::getFlippedStrictnessPredicateAndConstant(Pred, Op1C); in canonicalizeCmpWithConstant()
6880 CmpInst::Predicate Pred = I.getPredicate(); in canonicalizeICmpPredicate() local
6881 if (InstCombiner::isCanonicalPredicate(Pred)) in canonicalizeICmpPredicate()
6890 I.setPredicate(CmpInst::getInversePredicate(Pred)); in canonicalizeICmpPredicate()
6981 ICmpInst::Predicate Pred, NewPred; in foldICmpWithHighBitMask() local
6984 m_c_ICmp(Pred, m_OneUse(m_Shl(m_One(), m_Value(Y))), m_Value(X)))) { in foldICmpWithHighBitMask()
6985 switch (Pred) { in foldICmpWithHighBitMask()
6995 } else if (match(&Cmp, m_c_ICmp(Pred, in foldICmpWithHighBitMask()
7004 switch (Pred) { in foldICmpWithHighBitMask()
7024 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldVectorCmp() local
7028 auto createCmpReverse = [&](CmpInst::Predicate Pred, Value *X, Value *Y) { in foldVectorCmp() argument
7029 Value *V = Builder.CreateCmp(Pred, X, Y, Cmp.getName()); in foldVectorCmp()
7042 return createCmpReverse(Pred, V1, V2); in foldVectorCmp()
7046 return createCmpReverse(Pred, V1, RHS); in foldVectorCmp()
7050 return createCmpReverse(Pred, LHS, V2); in foldVectorCmp()
7062 Value *NewCmp = Builder.CreateCmp(Pred, V1, V2); in foldVectorCmp()
7083 Value *NewCmp = Builder.CreateCmp(Pred, V1, C); in foldVectorCmp()
7093 CmpInst::Predicate Pred = I.getPredicate(); in foldICmpOfUAddOv() local
7101 ((Pred == ICmpInst::ICMP_ULT && (Op1 == A || Op1 == B)) || in foldICmpOfUAddOv()
7102 (Pred == ICmpInst::ICMP_EQ && match(Op1, m_ZeroInt()) && in foldICmpOfUAddOv()
7104 (Pred == ICmpInst::ICMP_NE && match(Op1, m_AllOnes()) && in foldICmpOfUAddOv()
7111 Pred == ICmpInst::ICMP_UGT && (Op0 == A || Op0 == B)) in foldICmpOfUAddOv()
7187 Instruction *InstCombinerImpl::foldICmpCommutative(ICmpInst::Predicate Pred, in foldICmpCommutative() argument
7192 if (Instruction *NI = foldGEPICmp(GEP, Op1, Pred, CxtI)) in foldICmpCommutative()
7196 if (Instruction *NI = foldSelectICmp(Pred, SI, Op1, CxtI)) in foldICmpCommutative()
7200 if (Instruction *Res = foldICmpWithMinMax(CxtI, MinMax, Op1, Pred)) in foldICmpCommutative()
7208 return foldICmpAddOpConst(X, *C, Pred); in foldICmpCommutative()
7231 switch (Pred) { in foldICmpCommutative()
7263 if (Value *V = foldICmpWithLowBitMaskedVal(Pred, Op0, Op1, Q, *this)) in foldICmpCommutative()
7270 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1, in foldICmpCommutative()
7274 if (!ICmpInst::isUnsigned(Pred) && in foldICmpCommutative()
7276 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1, in foldICmpCommutative()
7285 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1, in foldICmpCommutative()
7289 if ((Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_SGE) && in foldICmpCommutative()
7291 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1, in foldICmpCommutative()
7386 ICmpInst::Predicate Pred = I.getPredicate(); in visitICmpInst() local
7390 if (Pred == ICmpInst::ICMP_UGT && C->isMaxSignedValue()) { in visitICmpInst()
7396 if (Pred == ICmpInst::ICMP_ULT && C->isMinSignedValue()) { in visitICmpInst()
7455 if (Value *Res = simplifyICmpInst(Pred, A, C, SQ)) { in visitICmpInst()
7456 Value *NewICMP = Builder.CreateICmp(Pred, B, D); in visitICmpInst()
7460 if (Value *Res = simplifyICmpInst(Pred, B, D, SQ)) { in visitICmpInst()
7461 Value *NewICMP = Builder.CreateICmp(Pred, A, C); in visitICmpInst()
7554 Value *Cmp = Builder.CreateICmp(Pred, SLTZero, Y, I.getName()); in visitICmpInst()
7673 ICmpInst::Predicate Pred; in foldFCmpIntToFPConst() local
7678 Pred = ICmpInst::ICMP_EQ; in foldFCmpIntToFPConst()
7682 Pred = LHSUnsigned ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
7686 Pred = LHSUnsigned ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
7690 Pred = LHSUnsigned ? ICmpInst::ICMP_ULT : ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
7694 Pred = LHSUnsigned ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
7698 Pred = ICmpInst::ICMP_NE; in foldFCmpIntToFPConst()
7717 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SLT || in foldFCmpIntToFPConst()
7718 Pred == ICmpInst::ICMP_SLE) in foldFCmpIntToFPConst()
7729 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_ULT || in foldFCmpIntToFPConst()
7730 Pred == ICmpInst::ICMP_ULE) in foldFCmpIntToFPConst()
7742 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT || in foldFCmpIntToFPConst()
7743 Pred == ICmpInst::ICMP_SGE) in foldFCmpIntToFPConst()
7753 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_UGT || in foldFCmpIntToFPConst()
7754 Pred == ICmpInst::ICMP_UGE) in foldFCmpIntToFPConst()
7772 switch (Pred) { in foldFCmpIntToFPConst()
7788 Pred = ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
7795 Pred = ICmpInst::ICMP_ULE; in foldFCmpIntToFPConst()
7801 Pred = ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
7813 Pred = ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
7820 Pred = ICmpInst::ICMP_UGT; in foldFCmpIntToFPConst()
7826 Pred = ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
7834 return new ICmpInst(Pred, LHSI->getOperand(0), in foldFCmpIntToFPConst()
7854 FCmpInst::Predicate Pred = I.getPredicate(); in foldFCmpReciprocalAndZero() local
7857 if ((Pred != FCmpInst::FCMP_OGT) && (Pred != FCmpInst::FCMP_OLT) && in foldFCmpReciprocalAndZero()
7858 (Pred != FCmpInst::FCMP_OGE) && (Pred != FCmpInst::FCMP_OLE)) in foldFCmpReciprocalAndZero()
7880 Pred = I.getSwappedPredicate(); in foldFCmpReciprocalAndZero()
7882 return new FCmpInst(Pred, LHSI->getOperand(1), RHSC, "", &I); in foldFCmpReciprocalAndZero()
7987 CmpInst::Predicate Pred = I.getPredicate(); in foldFCmpFNegCommonOp() local
7993 Pred = I.getSwappedPredicate(); in foldFCmpFNegCommonOp()
8002 return new FCmpInst(Pred, Op0, Zero, "", &I); in foldFCmpFNegCommonOp()
8007 const CmpInst::Predicate Pred = I.getPredicate(); in foldFCmpFSubIntoFCmp() local
8010 switch (Pred) { in foldFCmpFSubIntoFCmp()
8063 const CmpInst::Predicate Pred = I.getPredicate(); in visitFCmpInst() local
8065 if (Value *V = simplifyFCmpInst(Pred, Op0, Op1, I.getFastMathFlags(), in visitFCmpInst()
8073 switch (Pred) { in visitFCmpInst()
8105 if (Pred == CmpInst::FCMP_ORD || Pred == CmpInst::FCMP_UNO) { in visitFCmpInst()
8162 switch (C->isNegative() ? FCmpInst::getSwappedPredicate(Pred) : Pred) { in visitFCmpInst()
8194 if (Pred == FCmpInst::FCMP_OEQ) in visitFCmpInst()
8196 else if (Pred == FCmpInst::FCMP_UNE) in visitFCmpInst()
8214 if (FCmpInst::isEquality(Pred) && match(RHSC, m_AnyZeroFP()) && in visitFCmpInst()
8263 return new FCmpInst(Pred, X, Op1, "", &I); in visitFCmpInst()
8267 return new FCmpInst(Pred, Op0, Y, "", &I); in visitFCmpInst()
8272 return new FCmpInst(Pred, X, Y, "", &I); in visitFCmpInst()
8286 switch (Pred) { in visitFCmpInst()
8314 return new FCmpInst(Pred, X, NewC, "", &I); in visitFCmpInst()
8331 if (Pred == FCmpInst::FCMP_OLT) { in visitFCmpInst()
8345 return new FCmpInst(Pred, Op1, Op1, "", &I); in visitFCmpInst()
8349 return new FCmpInst(Pred, Op0, Op0, "", &I); in visitFCmpInst()
8353 return new FCmpInst(Pred, CanonLHS, CanonRHS, "", &I); in visitFCmpInst()