Lines Matching refs:Pred

76 static bool isSignTest(ICmpInst::Predicate &Pred, const APInt &C) {  in isSignTest()  argument
77 if (!ICmpInst::isSigned(Pred)) in isSignTest()
81 return ICmpInst::isRelational(Pred); in isSignTest()
84 if (Pred == ICmpInst::ICMP_SLT) { in isSignTest()
85 Pred = ICmpInst::ICMP_SLE; in isSignTest()
89 if (Pred == ICmpInst::ICMP_SGT) { in isSignTest()
90 Pred = ICmpInst::ICMP_SGE; in isSignTest()
1087 ICmpInst::Predicate Pred) { in foldICmpAddOpConst() argument
1096 if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_ULE) { in foldICmpAddOpConst()
1105 if (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_UGE) in foldICmpAddOpConst()
1117 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) in foldICmpAddOpConst()
1128 assert(Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE); in foldICmpAddOpConst()
1141 auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { in foldICmpShrConstConst() argument
1143 Pred = CmpInst::getInversePredicate(Pred); in foldICmpShrConstConst()
1144 return new ICmpInst(Pred, LHS, RHS); in foldICmpShrConstConst()
1200 auto getICmp = [&I](CmpInst::Predicate Pred, Value *LHS, Value *RHS) { in foldICmpShlConstConst() argument
1202 Pred = CmpInst::getInversePredicate(Pred); in foldICmpShlConstConst()
1203 return new ICmpInst(Pred, LHS, RHS); in foldICmpShlConstConst()
1330 ICmpInst::Predicate Pred; in foldIRemByPowerOfTwoToBitTest() local
1332 if (!match(&I, m_ICmp(Pred, m_OneUse(m_IRem(m_Value(X), m_Value(Y))), in foldIRemByPowerOfTwoToBitTest()
1340 return ICmpInst::Create(Instruction::ICmp, Pred, Masked, Zero); in foldIRemByPowerOfTwoToBitTest()
1347 ICmpInst::Predicate Pred; in foldSignBitTest() local
1348 if (!I.isEquality() || !match(&I, m_ICmp(Pred, m_Instruction(Val), m_Zero()))) in foldSignBitTest()
1370 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_SGE in foldSignBitTest()
1377 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithZero() local
1382 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpWithZero()
1386 return new ICmpInst(Pred, B, Cmp.getOperand(1)); in foldICmpWithZero()
1388 return new ICmpInst(Pred, A, Cmp.getOperand(1)); in foldICmpWithZero()
1401 ICmpInst::isEquality(Pred)) { in foldICmpWithZero()
1405 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1428 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithConstant() local
1432 if (Pred == ICmpInst::ICMP_UGT && match(Op1, m_ConstantInt(CI)) && in foldICmpWithConstant()
1451 auto *BoolInput = ConstantExpr::getCompare(Pred, Input, C); in foldICmpWithConstant()
1487 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithDominatingICmp() local
1500 ConstantRange CR = ConstantRange::makeExactICmpRegion(Pred, *C); in foldICmpWithDominatingICmp()
1518 bool IsSignBit = isSignBitCheck(Pred, *C, UnusedBit); in foldICmpWithDominatingICmp()
1541 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpTruncConstant() local
1546 if (Pred == ICmpInst::ICMP_SLT && match(X, m_Signum(m_Value(V)))) in foldICmpTruncConstant()
1561 return new ICmpInst(Pred, And, WideC); in foldICmpTruncConstant()
1573 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), NewRHS)); in foldICmpTruncConstant()
1583 if (isSignBitCheck(Pred, C, TrueIfSigned) && in foldICmpTruncConstant()
1608 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpXorConstant() local
1629 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1630 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1635 Pred = Cmp.getFlippedSignednessPredicate(); in foldICmpXorConstant()
1636 Pred = Cmp.getSwappedPredicate(Pred); in foldICmpXorConstant()
1637 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1642 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpXorConstant()
1650 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpXorConstant()
1869 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAndConstant() local
1871 if (isSignBitCheck(Pred, C, TrueIfNeg)) { in foldICmpAndConstant()
1903 Pred == CmpInst::ICMP_EQ ? CmpInst::ICMP_UGT : CmpInst::ICMP_ULE; in foldICmpAndConstant()
1914 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpOrConstant() local
1918 if (Pred == ICmpInst::ICMP_SLT && match(Or, m_Signum(m_Value(V)))) in foldICmpOrConstant()
1930 Pred = (Pred == CmpInst::ICMP_EQ) ? CmpInst::ICMP_ULE : CmpInst::ICMP_UGT; in foldICmpOrConstant()
1931 return new ICmpInst(Pred, OrOp0, OrOp1); in foldICmpOrConstant()
1941 return new ICmpInst(Pred, And, NewC); in foldICmpOrConstant()
1949 if (isSignBitCheck(Pred, C, TrueIfSigned) && in foldICmpOrConstant()
1964 Builder.CreateICmp(Pred, P, ConstantInt::getNullValue(P->getType())); in foldICmpOrConstant()
1966 Builder.CreateICmp(Pred, Q, ConstantInt::getNullValue(Q->getType())); in foldICmpOrConstant()
1967 auto BOpc = Pred == CmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpOrConstant()
1978 Value *Cmp12 = Builder.CreateICmp(Pred, X1, X2); in foldICmpOrConstant()
1979 Value *Cmp34 = Builder.CreateICmp(Pred, X3, X4); in foldICmpOrConstant()
1980 auto BOpc = Pred == CmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpOrConstant()
1997 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpMulConstant() local
1998 if (isSignTest(Pred, C) && Mul->hasNoSignedWrap()) { in foldICmpMulConstant()
2000 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpMulConstant()
2001 return new ICmpInst(Pred, Mul->getOperand(0), in foldICmpMulConstant()
2014 return new ICmpInst(Pred, Mul->getOperand(0), NewC); in foldICmpMulConstant()
2019 return new ICmpInst(Pred, Mul->getOperand(0), NewC); in foldICmpMulConstant()
2033 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpMulConstant()
2035 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SGE) in foldICmpMulConstant()
2039 if (Pred == ICmpInst::ICMP_SLE || Pred == ICmpInst::ICMP_SGT) in foldICmpMulConstant()
2044 if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE) in foldICmpMulConstant()
2048 if (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT) in foldICmpMulConstant()
2054 return NewC ? new ICmpInst(Pred, Mul->getOperand(0), NewC) : nullptr; in foldICmpMulConstant()
2067 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlOne() local
2075 if (Pred == ICmpInst::ICMP_ULT) in foldICmpShlOne()
2076 Pred = ICmpInst::ICMP_ULE; in foldICmpShlOne()
2077 else if (Pred == ICmpInst::ICMP_UGE) in foldICmpShlOne()
2078 Pred = ICmpInst::ICMP_UGT; in foldICmpShlOne()
2085 if (Pred == ICmpInst::ICMP_UGE) in foldICmpShlOne()
2086 Pred = ICmpInst::ICMP_EQ; in foldICmpShlOne()
2087 else if (Pred == ICmpInst::ICMP_ULT) in foldICmpShlOne()
2088 Pred = ICmpInst::ICMP_NE; in foldICmpShlOne()
2090 return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, CLog2)); in foldICmpShlOne()
2095 if (Pred == ICmpInst::ICMP_SLE) in foldICmpShlOne()
2099 if (Pred == ICmpInst::ICMP_SGT) in foldICmpShlOne()
2104 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) in foldICmpShlOne()
2109 if (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE) in foldICmpShlOne()
2113 return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, C.logBase2())); in foldICmpShlOne()
2137 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlConstant() local
2145 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpShlConstant()
2148 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2150 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2153 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2155 if (Pred == ICmpInst::ICMP_SLT) { in foldICmpShlConstant()
2162 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2167 if (isSignTest(Pred, C)) in foldICmpShlConstant()
2168 return new ICmpInst(Pred, X, Constant::getNullValue(ShType)); in foldICmpShlConstant()
2175 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpShlConstant()
2178 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2180 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2183 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2185 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpShlConstant()
2192 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2203 return new ICmpInst(Pred, And, LShrC); in foldICmpShlConstant()
2208 if (Shl->hasOneUse() && isSignBitCheck(Pred, C, TrueIfSigned)) { in foldICmpShlConstant()
2222 (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT)) { in foldICmpShlConstant()
2224 return new ICmpInst(Pred == ICmpInst::ICMP_ULE ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2230 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) { in foldICmpShlConstant()
2233 return new ICmpInst(Pred == ICmpInst::ICMP_ULT ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2253 return new ICmpInst(Pred, Builder.CreateTrunc(X, TruncTy), NewC); in foldICmpShlConstant()
2266 CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShrConstant() local
2268 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpShrConstant()
2280 isSignBitCheck(Pred, C, TrueIfSigned)) in foldICmpShrConstant()
2289 (Pred == CmpInst::ICMP_UGT || Pred == CmpInst::ICMP_ULT)) { in foldICmpShrConstant()
2290 bool IsUGT = Pred == CmpInst::ICMP_UGT; in foldICmpShrConstant()
2321 if (IsExact || Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_ULT) { in foldICmpShrConstant()
2327 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2329 if (Pred == CmpInst::ICMP_SGT) { in foldICmpShrConstant()
2334 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2336 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2343 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2351 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2355 if (Pred == CmpInst::ICMP_ULT) { in foldICmpShrConstant()
2361 if (Pred == CmpInst::ICMP_ULT || (Pred == CmpInst::ICMP_UGT && IsExact)) { in foldICmpShrConstant()
2366 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2368 if (Pred == CmpInst::ICMP_UGT) { in foldICmpShrConstant()
2372 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2391 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2395 if (Pred == CmpInst::ICMP_EQ) in foldICmpShrConstant()
2409 return new ICmpInst(Pred, And, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2421 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSRemConstant() local
2422 if (Pred != ICmpInst::ICMP_SGT && Pred != ICmpInst::ICMP_SLT && in foldICmpSRemConstant()
2423 Pred != ICmpInst::ICMP_EQ && Pred != ICmpInst::ICMP_NE) in foldICmpSRemConstant()
2438 if (((Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT) && in foldICmpSRemConstant()
2440 ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpSRemConstant()
2450 if (Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) in foldICmpSRemConstant()
2451 return new ICmpInst(Pred, And, ConstantInt::get(Ty, C)); in foldICmpSRemConstant()
2456 if (Pred == ICmpInst::ICMP_SGT) in foldICmpSRemConstant()
2469 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpUDivConstant() local
2481 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpUDivConstant()
2489 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpUDivConstant()
2502 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpDivConstant() local
2518 Value *XBig = Builder.CreateICmp(Pred, X, ConstantInt::get(Ty, C)); in foldICmpDivConstant()
2519 Value *YOne = Builder.CreateICmp(Pred, Y, ConstantInt::get(Ty, 1)); in foldICmpDivConstant()
2520 auto Logic = Pred == ICmpInst::ICMP_EQ ? Instruction::And : Instruction::Or; in foldICmpDivConstant()
2631 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpDivConstant()
2634 switch (Pred) { in foldICmpDivConstant()
2665 return new ICmpInst(Pred, X, ConstantInt::get(Ty, LoBound)); in foldICmpDivConstant()
2672 if (Pred == ICmpInst::ICMP_UGT) in foldICmpDivConstant()
2685 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSubConstant() local
2692 return new ICmpInst(Pred, Y, in foldICmpSubConstant()
2715 return new ICmpInst(Pred, X, Y); in foldICmpSubConstant()
2727 if (Pred == ICmpInst::ICMP_SGT && C.isAllOnes()) in foldICmpSubConstant()
2731 if (Pred == ICmpInst::ICMP_SGT && C.isZero()) in foldICmpSubConstant()
2735 if (Pred == ICmpInst::ICMP_SLT && C.isZero()) in foldICmpSubConstant()
2739 if (Pred == ICmpInst::ICMP_SLT && C.isOne()) in foldICmpSubConstant()
2748 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && in foldICmpSubConstant()
2754 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == C) in foldICmpSubConstant()
2777 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpAddConstant() local
2783 (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT)) || in foldICmpAddConstant()
2785 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULT))) { in foldICmpAddConstant()
2794 return new ICmpInst(Pred, X, ConstantInt::get(Ty, NewC)); in foldICmpAddConstant()
2797 auto CR = ConstantRange::makeExactICmpRegion(Pred, C).subtract(*C2); in foldICmpAddConstant()
2819 if (Pred == CmpInst::ICMP_UGT && C == *C2 + SMax) in foldICmpAddConstant()
2823 if (Pred == CmpInst::ICMP_ULT && C == *C2 + SMin) in foldICmpAddConstant()
2827 if (Pred == CmpInst::ICMP_SGT && C == *C2 - 1) in foldICmpAddConstant()
2831 if (Pred == CmpInst::ICMP_SLT && C == *C2) in foldICmpAddConstant()
2840 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && (*C2 & (C - 1)) == 0) in foldICmpAddConstant()
2847 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == 0) in foldICmpAddConstant()
2854 if (Pred == ICmpInst::ICMP_UGT) in foldICmpAddConstant()
2972 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBitCast() local
2989 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_SLT || in foldICmpBitCast()
2990 Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT) && in foldICmpBitCast()
2992 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
2995 if (Pred == ICmpInst::ICMP_SLT && match(Op1, m_One())) in foldICmpBitCast()
2996 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), 1)); in foldICmpBitCast()
2999 if (Pred == ICmpInst::ICMP_SGT && match(Op1, m_AllOnes())) in foldICmpBitCast()
3000 return new ICmpInst(Pred, X, in foldICmpBitCast()
3009 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
3018 isSignBitCheck(Pred, *C, TrueIfSigned)) { in foldICmpBitCast()
3051 return new ICmpInst(Pred, BCSrcOp, Op1); in foldICmpBitCast()
3069 return new ICmpInst(Pred, Cast, ConstantInt::getNullValue(DstType)); in foldICmpBitCast()
3081 return new ICmpInst(Pred, NewCast, ConstantInt::getNullValue(NewType)); in foldICmpBitCast()
3108 return new ICmpInst(Pred, Extract, NewC); in foldICmpBitCast()
3157 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBinOpEqualityWithConstant() local
3158 bool isICMP_NE = Pred == ICmpInst::ICMP_NE; in foldICmpBinOpEqualityWithConstant()
3169 return new ICmpInst(Pred, NewRem, in foldICmpBinOpEqualityWithConstant()
3178 return new ICmpInst(Pred, BOp0, ConstantExpr::getSub(RHS, BOC)); in foldICmpBinOpEqualityWithConstant()
3183 return new ICmpInst(Pred, BOp0, NegVal); in foldICmpBinOpEqualityWithConstant()
3185 return new ICmpInst(Pred, NegVal, BOp1); in foldICmpBinOpEqualityWithConstant()
3189 return new ICmpInst(Pred, BOp0, Neg); in foldICmpBinOpEqualityWithConstant()
3199 return new ICmpInst(Pred, BOp0, ConstantExpr::getXor(RHS, BOC)); in foldICmpBinOpEqualityWithConstant()
3202 return new ICmpInst(Pred, BOp0, BOp1); in foldICmpBinOpEqualityWithConstant()
3214 return new ICmpInst(Pred, And, NotBOC); in foldICmpBinOpEqualityWithConstant()
3246 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpEqIntrinsicWithConstant() local
3253 return new ICmpInst(Pred, II->getArgOperand(0), ConstantInt::get(Ty, C)); in foldICmpEqIntrinsicWithConstant()
3258 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3265 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3279 return new ICmpInst(Pred, Builder.CreateAnd(II->getArgOperand(0), Mask1), in foldICmpEqIntrinsicWithConstant()
3290 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3304 return new ICmpInst(Pred, II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3315 return new ICmpInst(Pred, Or, Constant::getNullValue(Ty)); in foldICmpEqIntrinsicWithConstant()
3324 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_UGT; in foldICmpEqIntrinsicWithConstant()
3340 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithIntrinsic() local
3353 return new ICmpInst(Pred, IIOp0->getOperand(0), IIOp1->getOperand(0)); in foldICmpIntrinsicWithIntrinsic()
3364 return new ICmpInst(Pred, IIOp0->getOperand(0), IIOp1->getOperand(0)); in foldICmpIntrinsicWithIntrinsic()
3378 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpInstWithConstantAllowUndef() local
3388 return new ICmpInst(Pred, II->getArgOperand(0), Cmp.getOperand(1)); in foldICmpInstWithConstantAllowUndef()
3464 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithConstant() local
3469 if (C == BitWidth - 1 && Pred == ICmpInst::ICMP_UGT) in foldICmpIntrinsicWithConstant()
3473 if (C == BitWidth && Pred == ICmpInst::ICMP_ULT) in foldICmpIntrinsicWithConstant()
3480 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
3488 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
3502 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
3510 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
3573 Instruction *InstCombinerImpl::foldSelectICmp(ICmpInst::Predicate Pred, in foldSelectICmp() argument
3579 if (Value *Res = simplifyICmpInst(Pred, Op, RHS, SQ)) in foldSelectICmp()
3581 if (Optional<bool> Impl = isImpliedCondition(SI->getCondition(), Pred, Op, in foldSelectICmp()
3619 Op1 = Builder.CreateICmp(Pred, SI->getOperand(1), RHS, I.getName()); in foldSelectICmp()
3621 Op2 = Builder.CreateICmp(Pred, SI->getOperand(2), RHS, I.getName()); in foldSelectICmp()
3978 ICmpInst::Predicate Pred; in foldMultiplicationOverflowCheck() local
3985 match(&I, m_c_ICmp(Pred, in foldMultiplicationOverflowCheck()
3992 switch (Pred) { in foldMultiplicationOverflowCheck()
4005 m_c_ICmp(Pred, m_Value(Y), in foldMultiplicationOverflowCheck()
4012 NeedNegation = Pred == ICmpInst::Predicate::ICMP_EQ; in foldMultiplicationOverflowCheck()
4049 CmpInst::Predicate Pred; in foldICmpXNegX() local
4051 if (!match(&I, m_c_ICmp(Pred, m_NSWNeg(m_Value(X)), m_Deferred(X)))) in foldICmpXNegX()
4054 if (ICmpInst::isSigned(Pred)) in foldICmpXNegX()
4055 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpXNegX()
4056 else if (ICmpInst::isUnsigned(Pred)) in foldICmpXNegX()
4057 Pred = ICmpInst::getSignedPredicate(Pred); in foldICmpXNegX()
4060 return ICmpInst::Create(Instruction::ICmp, Pred, X, in foldICmpXNegX()
4082 const CmpInst::Predicate Pred = I.getPredicate(); in foldICmpBinOp() local
4088 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
4089 return new ICmpInst(Pred, Builder.CreateNot(Op1), X); in foldICmpBinOp()
4092 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
4093 return new ICmpInst(Pred, X, Builder.CreateNot(Op0)); in foldICmpBinOp()
4100 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) { in foldICmpBinOp()
4102 return new ICmpInst(Pred, Builder.CreateSub(C2, X), Op1); in foldICmpBinOp()
4107 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) { in foldICmpBinOp()
4109 return new ICmpInst(Pred, Op0, Builder.CreateSub(C2, X)); in foldICmpBinOp()
4121 if ((Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE) && in foldICmpBinOp()
4125 Pred == ICmpInst::ICMP_ULT ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ; in foldICmpBinOp()
4130 if ((Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE) && in foldICmpBinOp()
4134 Pred == ICmpInst::ICMP_UGT ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ; in foldICmpBinOp()
4143 ICmpInst::isEquality(Pred) || in foldICmpBinOp()
4144 (CmpInst::isUnsigned(Pred) && BO0->hasNoUnsignedWrap()) || in foldICmpBinOp()
4145 (CmpInst::isSigned(Pred) && BO0->hasNoSignedWrap()); in foldICmpBinOp()
4148 ICmpInst::isEquality(Pred) || in foldICmpBinOp()
4149 (CmpInst::isUnsigned(Pred) && BO1->hasNoUnsignedWrap()) || in foldICmpBinOp()
4150 (CmpInst::isSigned(Pred) && BO1->hasNoSignedWrap()); in foldICmpBinOp()
4167 return new ICmpInst(Pred, A == Op1 ? B : A, in foldICmpBinOp()
4173 return new ICmpInst(Pred, Constant::getNullValue(Op0->getType()), in foldICmpBinOp()
4199 return new ICmpInst(Pred, Y, Z); in foldICmpBinOp()
4203 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SLT && in foldICmpBinOp()
4208 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SGE && in foldICmpBinOp()
4213 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SLE && match(B, m_One())) in foldICmpBinOp()
4217 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_SGT && match(B, m_One())) in foldICmpBinOp()
4221 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SGT && in foldICmpBinOp()
4226 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SLE && in foldICmpBinOp()
4231 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SGE && match(D, m_One())) in foldICmpBinOp()
4235 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_SLT && match(D, m_One())) in foldICmpBinOp()
4248 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_ULE && match(B, m_One())) in foldICmpBinOp()
4252 if (A && NoOp0WrapProblem && Pred == CmpInst::ICMP_UGT && match(B, m_One())) in foldICmpBinOp()
4256 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_UGE && match(D, m_One())) in foldICmpBinOp()
4260 if (C && NoOp1WrapProblem && Pred == CmpInst::ICMP_ULT && match(D, m_One())) in foldICmpBinOp()
4285 return new ICmpInst(Pred, NewAdd, C); in foldICmpBinOp()
4292 return new ICmpInst(Pred, A, NewAdd); in foldICmpBinOp()
4297 ICmpInst::isEquality(Pred)) { in foldICmpBinOp()
4300 return new ICmpInst(Pred, A, NewAdd); in foldICmpBinOp()
4321 return new ICmpInst(Pred, Constant::getNullValue(Op1->getType()), B); in foldICmpBinOp()
4324 return new ICmpInst(Pred, D, Constant::getNullValue(Op0->getType())); in foldICmpBinOp()
4328 if (A == Op1 && (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
4329 return new ICmpInst(Pred, B, A); in foldICmpBinOp()
4331 if (C == Op0 && (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
4332 return new ICmpInst(Pred, C, D); in foldICmpBinOp()
4334 if (A == Op1 && (Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_ULT) && in foldICmpBinOp()
4336 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), B, A); in foldICmpBinOp()
4338 if (C == Op0 && (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT) && in foldICmpBinOp()
4340 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), C, D); in foldICmpBinOp()
4344 return new ICmpInst(Pred, A, C); in foldICmpBinOp()
4348 return new ICmpInst(Pred, D, B); in foldICmpBinOp()
4351 if (NoOp0WrapProblem && ICmpInst::isSigned(Pred)) { in foldICmpBinOp()
4370 return new ICmpInst(Pred, X, Y); in foldICmpBinOp()
4384 switch (SRem == BO0 ? ICmpInst::getSwappedPredicate(Pred) : Pred) { in foldICmpBinOp()
4411 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4445 return new ICmpInst(Pred, And1, And2); in foldICmpBinOp()
4454 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4459 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4464 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4473 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4483 if (match(BO0, BitwiseAnd) && Pred == ICmpInst::ICMP_ULT) { in foldICmpBinOp()
4506 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithMinMax() local
4516 Pred = Cmp.getSwappedPredicate(); in foldICmpWithMinMax()
4523 if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_SGE) in foldICmpWithMinMax()
4528 if (Pred == CmpInst::ICMP_NE || Pred == CmpInst::ICMP_SLT) in foldICmpWithMinMax()
4540 if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_SLE) in foldICmpWithMinMax()
4545 if (Pred == CmpInst::ICMP_NE || Pred == CmpInst::ICMP_SGT) in foldICmpWithMinMax()
4557 if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_UGE) in foldICmpWithMinMax()
4562 if (Pred == CmpInst::ICMP_NE || Pred == CmpInst::ICMP_ULT) in foldICmpWithMinMax()
4574 if (Pred == CmpInst::ICMP_EQ || Pred == CmpInst::ICMP_ULE) in foldICmpWithMinMax()
4579 if (Pred == CmpInst::ICMP_NE || Pred == CmpInst::ICMP_UGT) in foldICmpWithMinMax()
4596 const CmpInst::Predicate Pred = I.getPredicate(); in foldICmpEquality() local
4601 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
4611 return new ICmpInst(Pred, A, Xor); in foldICmpEquality()
4616 return new ICmpInst(Pred, B, D); in foldICmpEquality()
4618 return new ICmpInst(Pred, B, C); in foldICmpEquality()
4620 return new ICmpInst(Pred, A, D); in foldICmpEquality()
4622 return new ICmpInst(Pred, A, C); in foldICmpEquality()
4629 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
4658 return new ICmpInst(Pred, Op1, Constant::getNullValue(Op1->getType())); in foldICmpEquality()
4671 return new ICmpInst(Pred, And, Constant::getNullValue(And->getType())); in foldICmpEquality()
4685 return new ICmpInst(Pred, A, Builder.CreateTrunc(B, A->getType())); in foldICmpEquality()
4701 Pred == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT; in foldICmpEquality()
4718 return new ICmpInst(Pred, And, Constant::getNullValue(Cst1->getType())); in foldICmpEquality()
4742 return new ICmpInst(Pred, Mask, Builder.getInt(CmpV)); in foldICmpEquality()
4768 return Pred == ICmpInst::ICMP_EQ in foldICmpEquality()
4784 return new ICmpInst(Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_ULT in foldICmpEquality()
4794 ICmpInst::Predicate Pred = ICmp.getPredicate(); in foldICmpWithTrunc() local
4808 if (decomposeBitTestICmp(Op0, Op1, Pred, X, Mask, true /* WithTrunc */)) { in foldICmpWithTrunc()
4811 return new ICmpInst(Pred, And, Zero); in foldICmpWithTrunc()
4815 if (Pred == ICmpInst::ICMP_ULT && C->isNegatedPowerOf2()) { in foldICmpWithTrunc()
4823 if (Pred == ICmpInst::ICMP_UGT && (~*C).isPowerOf2()) { in foldICmpWithTrunc()
5482 ICmpInst::Predicate Pred = I.getPredicate(); in foldICmpUsingKnownBits() local
5524 return new ICmpInst(Pred, ConstantExpr::getIntegerValue(Ty, Op0Min), Op1); in foldICmpUsingKnownBits()
5526 return new ICmpInst(Pred, Op0, ConstantExpr::getIntegerValue(Ty, Op1Min)); in foldICmpUsingKnownBits()
5543 switch (Pred) { in foldICmpUsingKnownBits()
5607 switch (Pred) { in foldICmpUsingKnownBits()
5614 I, ConstantInt::getBool(I.getType(), Pred == CmpInst::ICMP_NE)); in foldICmpUsingKnownBits()
5642 Pred == CmpInst::ICMP_EQ ? CmpInst::ICMP_UGE : CmpInst::ICMP_ULT; in foldICmpUsingKnownBits()
5730 ICmpInst::Predicate Pred; in foldICmpUsingBoolRange() local
5734 if (match(&I, m_c_ICmp(Pred, m_Value(X), m_OneUse(m_ZExt(m_Value(Y))))) && in foldICmpUsingBoolRange()
5735 Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULT) in foldICmpUsingBoolRange()
5740 if (match(&I, m_c_ICmp(Pred, m_Value(X), m_OneUse(m_SExt(m_Value(Y))))) && in foldICmpUsingBoolRange()
5741 Y->getType()->isIntOrIntVectorTy(1) && Pred == ICmpInst::ICMP_ULE) in foldICmpUsingBoolRange()
5748 InstCombiner::getFlippedStrictnessPredicateAndConstant(CmpInst::Predicate Pred, in getFlippedStrictnessPredicateAndConstant() argument
5750 assert(ICmpInst::isRelational(Pred) && ICmpInst::isIntPredicate(Pred) && in getFlippedStrictnessPredicateAndConstant()
5754 bool IsSigned = ICmpInst::isSigned(Pred); in getFlippedStrictnessPredicateAndConstant()
5756 CmpInst::Predicate UnsignedPred = ICmpInst::getUnsignedPredicate(Pred); in getFlippedStrictnessPredicateAndConstant()
5804 CmpInst::Predicate NewPred = CmpInst::getFlippedStrictnessPredicate(Pred); in getFlippedStrictnessPredicateAndConstant()
5817 ICmpInst::Predicate Pred = I.getPredicate(); in canonicalizeCmpWithConstant() local
5818 if (ICmpInst::isEquality(Pred) || !ICmpInst::isIntPredicate(Pred) || in canonicalizeCmpWithConstant()
5819 InstCombiner::isCanonicalPredicate(Pred)) in canonicalizeCmpWithConstant()
5829 InstCombiner::getFlippedStrictnessPredicateAndConstant(Pred, Op1C); in canonicalizeCmpWithConstant()
5840 CmpInst::Predicate Pred = I.getPredicate(); in canonicalizeICmpPredicate() local
5841 if (InstCombiner::isCanonicalPredicate(Pred)) in canonicalizeICmpPredicate()
5850 I.setPredicate(CmpInst::getInversePredicate(Pred)); in canonicalizeICmpPredicate()
5941 ICmpInst::Predicate Pred, NewPred; in foldICmpWithHighBitMask() local
5944 m_c_ICmp(Pred, m_OneUse(m_Shl(m_One(), m_Value(Y))), m_Value(X)))) { in foldICmpWithHighBitMask()
5945 switch (Pred) { in foldICmpWithHighBitMask()
5955 } else if (match(&Cmp, m_c_ICmp(Pred, in foldICmpWithHighBitMask()
5964 switch (Pred) { in foldICmpWithHighBitMask()
5984 const CmpInst::Predicate Pred = Cmp.getPredicate(); in foldVectorCmp() local
5997 Value *NewCmp = Builder.CreateCmp(Pred, V1, V2); in foldVectorCmp()
6018 Value *NewCmp = Builder.CreateCmp(Pred, V1, C); in foldVectorCmp()
6028 CmpInst::Predicate Pred = I.getPredicate(); in foldICmpOfUAddOv() local
6036 ((Pred == ICmpInst::ICMP_ULT && (Op1 == A || Op1 == B)) || in foldICmpOfUAddOv()
6037 (Pred == ICmpInst::ICMP_EQ && match(Op1, m_ZeroInt()) && in foldICmpOfUAddOv()
6039 (Pred == ICmpInst::ICMP_NE && match(Op1, m_AllOnes()) && in foldICmpOfUAddOv()
6046 Pred == ICmpInst::ICMP_UGT && (Op0 == A || Op0 == B)) in foldICmpOfUAddOv()
6206 ICmpInst::Predicate Pred = I.getPredicate(); in visitICmpInst() local
6210 if (Pred == ICmpInst::ICMP_UGT && C->isMaxSignedValue()) { in visitICmpInst()
6216 if (Pred == ICmpInst::ICMP_ULT && C->isMinSignedValue()) { in visitICmpInst()
6450 ICmpInst::Predicate Pred; in foldFCmpIntToFPConst() local
6455 Pred = ICmpInst::ICMP_EQ; in foldFCmpIntToFPConst()
6459 Pred = LHSUnsigned ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
6463 Pred = LHSUnsigned ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
6467 Pred = LHSUnsigned ? ICmpInst::ICMP_ULT : ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
6471 Pred = LHSUnsigned ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
6475 Pred = ICmpInst::ICMP_NE; in foldFCmpIntToFPConst()
6496 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SLT || in foldFCmpIntToFPConst()
6497 Pred == ICmpInst::ICMP_SLE) in foldFCmpIntToFPConst()
6508 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_ULT || in foldFCmpIntToFPConst()
6509 Pred == ICmpInst::ICMP_ULE) in foldFCmpIntToFPConst()
6521 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT || in foldFCmpIntToFPConst()
6522 Pred == ICmpInst::ICMP_SGE) in foldFCmpIntToFPConst()
6532 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_UGT || in foldFCmpIntToFPConst()
6533 Pred == ICmpInst::ICMP_UGE) in foldFCmpIntToFPConst()
6554 switch (Pred) { in foldFCmpIntToFPConst()
6570 Pred = ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
6577 Pred = ICmpInst::ICMP_ULE; in foldFCmpIntToFPConst()
6583 Pred = ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
6595 Pred = ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
6602 Pred = ICmpInst::ICMP_UGT; in foldFCmpIntToFPConst()
6608 Pred = ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
6616 return new ICmpInst(Pred, LHSI->getOperand(0), RHSInt); in foldFCmpIntToFPConst()
6635 FCmpInst::Predicate Pred = I.getPredicate(); in foldFCmpReciprocalAndZero() local
6638 if ((Pred != FCmpInst::FCMP_OGT) && (Pred != FCmpInst::FCMP_OLT) && in foldFCmpReciprocalAndZero()
6639 (Pred != FCmpInst::FCMP_OGE) && (Pred != FCmpInst::FCMP_OLE)) in foldFCmpReciprocalAndZero()
6661 Pred = I.getSwappedPredicate(); in foldFCmpReciprocalAndZero()
6663 return new FCmpInst(Pred, LHSI->getOperand(1), RHSC, "", &I); in foldFCmpReciprocalAndZero()
6730 CmpInst::Predicate Pred = I.getPredicate(); in foldFCmpFNegCommonOp() local
6736 Pred = I.getSwappedPredicate(); in foldFCmpFNegCommonOp()
6745 return new FCmpInst(Pred, Op0, Zero, "", &I); in foldFCmpFNegCommonOp()
6759 const CmpInst::Predicate Pred = I.getPredicate(); in visitFCmpInst() local
6761 if (Value *V = simplifyFCmpInst(Pred, Op0, Op1, I.getFastMathFlags(), in visitFCmpInst()
6769 switch (Pred) { in visitFCmpInst()
6793 if (Pred == CmpInst::FCMP_ORD || Pred == CmpInst::FCMP_UNO) { in visitFCmpInst()
6876 return new FCmpInst(Pred, X, Y, "", &I); in visitFCmpInst()
6890 switch (Pred) { in visitFCmpInst()
6918 return new FCmpInst(Pred, X, NewC, "", &I); in visitFCmpInst()
6936 if (Pred == FCmpInst::FCMP_OLT) { in visitFCmpInst()