Lines Matching refs:ICmpInst
66 static bool hasBranchUse(ICmpInst &I) { in hasBranchUse()
77 static bool isSignTest(ICmpInst::Predicate &Pred, const APInt &C) { in isSignTest()
78 if (!ICmpInst::isSigned(Pred)) in isSignTest()
82 return ICmpInst::isRelational(Pred); in isSignTest()
85 if (Pred == ICmpInst::ICMP_SLT) { in isSignTest()
86 Pred = ICmpInst::ICMP_SLE; in isSignTest()
90 if (Pred == ICmpInst::ICMP_SGT) { in isSignTest()
91 Pred = ICmpInst::ICMP_SGE; in isSignTest()
332 return new ICmpInst(ICmpInst::ICMP_EQ, Idx, FirstTrueIdx); in foldCmpLoadFromIndexedGlobal()
352 return new ICmpInst(ICmpInst::ICMP_NE, Idx, FirstFalseIdx); in foldCmpLoadFromIndexedGlobal()
374 return new ICmpInst(ICmpInst::ICMP_ULT, Idx, End); in foldCmpLoadFromIndexedGlobal()
388 return new ICmpInst(ICmpInst::ICMP_UGT, Idx, End); in foldCmpLoadFromIndexedGlobal()
409 return new ICmpInst(ICmpInst::ICMP_NE, V, ConstantInt::get(Ty, 0)); in foldCmpLoadFromIndexedGlobal()
807 ICmpInst::Predicate Cond, in transformToIndexedCompare()
841 return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Index, NewRHS); in transformToIndexedCompare()
847 ICmpInst::Predicate Cond, in foldGEPICmp()
854 if (ICmpInst::isSigned(Cond)) in foldGEPICmp()
875 return new ICmpInst(ICmpInst::getSignedPredicate(Cond), Offset, in foldGEPICmp()
879 if (GEPLHS->isInBounds() && ICmpInst::isEquality(Cond) && in foldGEPICmp()
905 return new ICmpInst(Cond, Base, in foldGEPICmp()
925 return new ICmpInst(Cond, GEPLHS->getOperand(0), GEPRHS->getOperand(0)); in foldGEPICmp()
953 Value *Cmp = Builder.CreateICmp(ICmpInst::getSignedPredicate(Cond), in foldGEPICmp()
968 ICmpInst::getSwappedPredicate(Cond), I); in foldGEPICmp()
1000 ConstantInt::get(I.getType(), ICmpInst::isTrueWhenEqual(Cond))); in foldGEPICmp()
1006 return new ICmpInst(ICmpInst::getSignedPredicate(Cond), LHSV, RHSV); in foldGEPICmp()
1017 return new ICmpInst(ICmpInst::getSignedPredicate(Cond), L, R); in foldGEPICmp()
1026 Instruction *InstCombinerImpl::foldAllocaCmp(ICmpInst &ICI, in foldAllocaCmp()
1072 } else if (isa<ICmpInst>(V)) { in foldAllocaCmp()
1105 ICmpInst::Predicate Pred) { in foldICmpAddOpConst()
1114 if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_ULE) { in foldICmpAddOpConst()
1117 return new ICmpInst(ICmpInst::ICMP_UGT, X, R); in foldICmpAddOpConst()
1123 if (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_UGE) in foldICmpAddOpConst()
1124 return new ICmpInst(ICmpInst::ICMP_ULT, X, in foldICmpAddOpConst()
1135 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) in foldICmpAddOpConst()
1136 return new ICmpInst(ICmpInst::ICMP_SGT, X, in foldICmpAddOpConst()
1146 assert(Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE); in foldICmpAddOpConst()
1147 return new ICmpInst(ICmpInst::ICMP_SLT, X, in foldICmpAddOpConst()
1154 Instruction *InstCombinerImpl::foldICmpShrConstConst(ICmpInst &I, Value *A, in foldICmpShrConstConst()
1162 return new ICmpInst(Pred, LHS, RHS); in foldICmpShrConstConst()
1213 Instruction *InstCombinerImpl::foldICmpShlConstConst(ICmpInst &I, Value *A, in foldICmpShlConstConst()
1221 return new ICmpInst(Pred, LHS, RHS); in foldICmpShlConstConst()
1257 static Instruction *processUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B, in processUGT_ADDCST_ADD()
1345 Instruction *InstCombinerImpl::foldIRemByPowerOfTwoToBitTest(ICmpInst &I) { in foldIRemByPowerOfTwoToBitTest()
1349 ICmpInst::Predicate Pred; in foldIRemByPowerOfTwoToBitTest()
1359 return ICmpInst::Create(Instruction::ICmp, Pred, Masked, Zero); in foldIRemByPowerOfTwoToBitTest()
1364 Instruction *InstCombinerImpl::foldSignBitTest(ICmpInst &I) { in foldSignBitTest()
1366 ICmpInst::Predicate Pred; in foldSignBitTest()
1377 if (!match(C, m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_EQ, in foldSignBitTest()
1388 return ICmpInst::Create(Instruction::ICmp, in foldSignBitTest()
1389 Pred == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_SGE in foldSignBitTest()
1390 : ICmpInst::ICMP_SLT, in foldSignBitTest()
1395 Instruction *InstCombinerImpl::foldICmpWithZero(ICmpInst &Cmp) { in foldICmpWithZero()
1401 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpWithZero()
1406 return new ICmpInst(Pred, B, Cmp.getOperand(1)); in foldICmpWithZero()
1408 return new ICmpInst(Pred, A, Cmp.getOperand(1)); in foldICmpWithZero()
1421 ICmpInst::isEquality(Pred)) { in foldICmpWithZero()
1425 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpWithZero()
1436 Instruction *InstCombinerImpl::foldICmpWithConstant(ICmpInst &Cmp) { in foldICmpWithConstant()
1452 if (Pred == ICmpInst::ICMP_UGT && match(Op1, m_ConstantInt(CI)) && in foldICmpWithConstant()
1482 Instruction *InstCombinerImpl::foldICmpWithDominatingICmp(ICmpInst &Cmp) { in foldICmpWithDominatingICmp()
1509 ICmpInst::Predicate DomPred; in foldICmpWithDominatingICmp()
1543 return new ICmpInst(ICmpInst::ICMP_EQ, X, Builder.getInt(*EqC)); in foldICmpWithDominatingICmp()
1545 return new ICmpInst(ICmpInst::ICMP_NE, X, Builder.getInt(*NeC)); in foldICmpWithDominatingICmp()
1552 Instruction *InstCombinerImpl::foldICmpTruncConstant(ICmpInst &Cmp, in foldICmpTruncConstant()
1555 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpTruncConstant()
1560 if (Pred == ICmpInst::ICMP_SLT && match(X, m_Signum(m_Value(V)))) in foldICmpTruncConstant()
1561 return new ICmpInst(ICmpInst::ICMP_SLT, V, in foldICmpTruncConstant()
1577 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), NewRHS)); in foldICmpTruncConstant()
1585 Instruction *InstCombinerImpl::foldICmpXorConstant(ICmpInst &Cmp, in foldICmpXorConstant()
1596 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpXorConstant()
1607 return new ICmpInst(ICmpInst::ICMP_SGT, X, in foldICmpXorConstant()
1610 return new ICmpInst(ICmpInst::ICMP_SLT, X, in foldICmpXorConstant()
1618 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1625 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), C ^ *XorC)); in foldICmpXorConstant()
1630 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpXorConstant()
1633 return new ICmpInst(ICmpInst::ICMP_ULT, X, Y); in foldICmpXorConstant()
1636 return new ICmpInst(ICmpInst::ICMP_UGT, X, Y); in foldICmpXorConstant()
1638 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpXorConstant()
1641 return new ICmpInst(ICmpInst::ICMP_UGT, X, in foldICmpXorConstant()
1645 return new ICmpInst(ICmpInst::ICMP_UGT, X, in foldICmpXorConstant()
1652 Instruction *InstCombinerImpl::foldICmpAndShift(ICmpInst &Cmp, in foldICmpAndShift()
1707 if (Cmp.getPredicate() == ICmpInst::ICMP_EQ) in foldICmpAndShift()
1709 if (Cmp.getPredicate() == ICmpInst::ICMP_NE) in foldICmpAndShift()
1714 return new ICmpInst(Cmp.getPredicate(), in foldICmpAndShift()
1738 Instruction *InstCombinerImpl::foldICmpAndConstConst(ICmpInst &Cmp, in foldICmpAndConstConst()
1741 bool isICMP_NE = Cmp.getPredicate() == ICmpInst::ICMP_NE; in foldICmpAndConstConst()
1764 auto NewPred = isICMP_NE ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_SGE; in foldICmpAndConstConst()
1765 return new ICmpInst(NewPred, X, Zero); in foldICmpAndConstConst()
1773 auto NewPred = isICMP_NE ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT; in foldICmpAndConstConst()
1774 return new ICmpInst(NewPred, X, NegBOC); in foldICmpAndConstConst()
1798 return new ICmpInst(Cmp.getPredicate(), NewAnd, ZextC1); in foldICmpAndConstConst()
1846 Instruction *InstCombinerImpl::foldICmpAndConstant(ICmpInst &Cmp, in foldICmpAndConstant()
1876 return new ICmpInst(NewPred, X, SubOne(cast<Constant>(Cmp.getOperand(1)))); in foldICmpAndConstant()
1893 return new ICmpInst(NewPred, Trunc, Constant::getNullValue(NTy)); in foldICmpAndConstant()
1901 Instruction *InstCombinerImpl::foldICmpOrConstant(ICmpInst &Cmp, in foldICmpOrConstant()
1904 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpOrConstant()
1908 if (Pred == ICmpInst::ICMP_SLT && match(Or, m_Signum(m_Value(V)))) in foldICmpOrConstant()
1909 return new ICmpInst(ICmpInst::ICMP_SLT, V, in foldICmpOrConstant()
1921 return new ICmpInst(Pred, OrOp0, OrOp1); in foldICmpOrConstant()
1931 return new ICmpInst(Pred, And, NewC); in foldICmpOrConstant()
1967 Instruction *InstCombinerImpl::foldICmpMulConstant(ICmpInst &Cmp, in foldICmpMulConstant()
1976 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpMulConstant()
1979 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpMulConstant()
1980 return new ICmpInst(Pred, Mul->getOperand(0), in foldICmpMulConstant()
1990 return new ICmpInst(Pred, Mul->getOperand(0), NewC); in foldICmpMulConstant()
1995 return new ICmpInst(Pred, Mul->getOperand(0), NewC); in foldICmpMulConstant()
2003 static Instruction *foldICmpShlOne(ICmpInst &Cmp, Instruction *Shl, in foldICmpShlOne()
2012 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlOne()
2020 if (Pred == ICmpInst::ICMP_ULT) in foldICmpShlOne()
2021 Pred = ICmpInst::ICMP_ULE; in foldICmpShlOne()
2022 else if (Pred == ICmpInst::ICMP_UGE) in foldICmpShlOne()
2023 Pred = ICmpInst::ICMP_UGT; in foldICmpShlOne()
2030 if (Pred == ICmpInst::ICMP_UGE) in foldICmpShlOne()
2031 Pred = ICmpInst::ICMP_EQ; in foldICmpShlOne()
2032 else if (Pred == ICmpInst::ICMP_ULT) in foldICmpShlOne()
2033 Pred = ICmpInst::ICMP_NE; in foldICmpShlOne()
2035 return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, CLog2)); in foldICmpShlOne()
2040 if (Pred == ICmpInst::ICMP_SLE) in foldICmpShlOne()
2041 return new ICmpInst(ICmpInst::ICMP_EQ, Y, BitWidthMinusOne); in foldICmpShlOne()
2044 if (Pred == ICmpInst::ICMP_SGT) in foldICmpShlOne()
2045 return new ICmpInst(ICmpInst::ICMP_NE, Y, BitWidthMinusOne); in foldICmpShlOne()
2049 if (Pred == ICmpInst::ICMP_SLT || Pred == ICmpInst::ICMP_SLE) in foldICmpShlOne()
2050 return new ICmpInst(ICmpInst::ICMP_EQ, Y, BitWidthMinusOne); in foldICmpShlOne()
2054 if (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SGE) in foldICmpShlOne()
2055 return new ICmpInst(ICmpInst::ICMP_NE, Y, BitWidthMinusOne); in foldICmpShlOne()
2058 return new ICmpInst(Pred, Y, ConstantInt::get(ShiftType, C.logBase2())); in foldICmpShlOne()
2065 Instruction *InstCombinerImpl::foldICmpShlConstant(ICmpInst &Cmp, in foldICmpShlConstant()
2082 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpShlConstant()
2090 if (Pred == ICmpInst::ICMP_SGT) { in foldICmpShlConstant()
2093 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2095 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2098 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2100 if (Pred == ICmpInst::ICMP_SLT) { in foldICmpShlConstant()
2107 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2113 return new ICmpInst(Pred, X, Constant::getNullValue(ShType)); in foldICmpShlConstant()
2120 if (Pred == ICmpInst::ICMP_UGT) { in foldICmpShlConstant()
2123 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2125 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_NE) && in foldICmpShlConstant()
2128 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2130 if (Pred == ICmpInst::ICMP_ULT) { in foldICmpShlConstant()
2137 return new ICmpInst(Pred, X, ConstantInt::get(ShType, ShiftedC)); in foldICmpShlConstant()
2148 return new ICmpInst(Pred, And, LShrC); in foldICmpShlConstant()
2159 return new ICmpInst(TrueIfSigned ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ, in foldICmpShlConstant()
2167 (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT)) { in foldICmpShlConstant()
2169 return new ICmpInst(Pred == ICmpInst::ICMP_ULE ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2170 : ICmpInst::ICMP_NE, in foldICmpShlConstant()
2175 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) { in foldICmpShlConstant()
2178 return new ICmpInst(Pred == ICmpInst::ICMP_ULT ? ICmpInst::ICMP_EQ in foldICmpShlConstant()
2179 : ICmpInst::ICMP_NE, in foldICmpShlConstant()
2199 return new ICmpInst(Pred, Builder.CreateTrunc(X, TruncTy), NewC); in foldICmpShlConstant()
2206 Instruction *InstCombinerImpl::foldICmpShrConstant(ICmpInst &Cmp, in foldICmpShrConstant()
2215 return new ICmpInst(Pred, X, Cmp.getOperand(1)); in foldICmpShrConstant()
2245 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2252 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2260 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2266 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, ShiftedC)); in foldICmpShrConstant()
2285 return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2293 return new ICmpInst(Pred, And, ConstantInt::get(ShrTy, C << ShAmtVal)); in foldICmpShrConstant()
2299 Instruction *InstCombinerImpl::foldICmpSRemConstant(ICmpInst &Cmp, in foldICmpSRemConstant()
2305 const ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSRemConstant()
2306 if (Pred != ICmpInst::ICMP_SGT && Pred != ICmpInst::ICMP_SLT) in foldICmpSRemConstant()
2328 if (Pred == ICmpInst::ICMP_SGT) in foldICmpSRemConstant()
2329 return new ICmpInst(ICmpInst::ICMP_SGT, And, ConstantInt::getNullValue(Ty)); in foldICmpSRemConstant()
2334 return new ICmpInst(ICmpInst::ICMP_UGT, And, ConstantInt::get(Ty, SignMask)); in foldICmpSRemConstant()
2338 Instruction *InstCombinerImpl::foldICmpUDivConstant(ICmpInst &Cmp, in foldICmpUDivConstant()
2349 if (Cmp.getPredicate() == ICmpInst::ICMP_UGT) { in foldICmpUDivConstant()
2352 return new ICmpInst(ICmpInst::ICMP_ULE, Y, in foldICmpUDivConstant()
2357 if (Cmp.getPredicate() == ICmpInst::ICMP_ULT) { in foldICmpUDivConstant()
2359 return new ICmpInst(ICmpInst::ICMP_UGT, Y, in foldICmpUDivConstant()
2367 Instruction *InstCombinerImpl::foldICmpDivConstant(ICmpInst &Cmp, in foldICmpDivConstant()
2411 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpDivConstant()
2480 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpDivConstant()
2486 case ICmpInst::ICMP_EQ: in foldICmpDivConstant()
2490 return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SGE : in foldICmpDivConstant()
2491 ICmpInst::ICMP_UGE, X, in foldICmpDivConstant()
2494 return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SLT : in foldICmpDivConstant()
2495 ICmpInst::ICMP_ULT, X, in foldICmpDivConstant()
2499 case ICmpInst::ICMP_NE: in foldICmpDivConstant()
2503 return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SLT : in foldICmpDivConstant()
2504 ICmpInst::ICMP_ULT, X, in foldICmpDivConstant()
2507 return new ICmpInst(DivIsSigned ? ICmpInst::ICMP_SGE : in foldICmpDivConstant()
2508 ICmpInst::ICMP_UGE, X, in foldICmpDivConstant()
2513 case ICmpInst::ICMP_ULT: in foldICmpDivConstant()
2514 case ICmpInst::ICMP_SLT: in foldICmpDivConstant()
2519 return new ICmpInst(Pred, X, ConstantInt::get(Div->getType(), LoBound)); in foldICmpDivConstant()
2520 case ICmpInst::ICMP_UGT: in foldICmpDivConstant()
2521 case ICmpInst::ICMP_SGT: in foldICmpDivConstant()
2526 if (Pred == ICmpInst::ICMP_UGT) in foldICmpDivConstant()
2527 return new ICmpInst(ICmpInst::ICMP_UGE, X, in foldICmpDivConstant()
2529 return new ICmpInst(ICmpInst::ICMP_SGE, X, in foldICmpDivConstant()
2537 Instruction *InstCombinerImpl::foldICmpSubConstant(ICmpInst &Cmp, in foldICmpSubConstant()
2541 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpSubConstant()
2547 return new ICmpInst(Cmp.getPredicate(), Y, in foldICmpSubConstant()
2555 return new ICmpInst(Cmp.getSwappedPredicate(), Y, in foldICmpSubConstant()
2565 if (Pred == ICmpInst::ICMP_SGT && C.isAllOnesValue()) in foldICmpSubConstant()
2566 return new ICmpInst(ICmpInst::ICMP_SGE, X, Y); in foldICmpSubConstant()
2569 if (Pred == ICmpInst::ICMP_SGT && C.isNullValue()) in foldICmpSubConstant()
2570 return new ICmpInst(ICmpInst::ICMP_SGT, X, Y); in foldICmpSubConstant()
2573 if (Pred == ICmpInst::ICMP_SLT && C.isNullValue()) in foldICmpSubConstant()
2574 return new ICmpInst(ICmpInst::ICMP_SLT, X, Y); in foldICmpSubConstant()
2577 if (Pred == ICmpInst::ICMP_SLT && C.isOneValue()) in foldICmpSubConstant()
2578 return new ICmpInst(ICmpInst::ICMP_SLE, X, Y); in foldICmpSubConstant()
2586 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && in foldICmpSubConstant()
2588 return new ICmpInst(ICmpInst::ICMP_EQ, Builder.CreateOr(Y, C - 1), X); in foldICmpSubConstant()
2592 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == C) in foldICmpSubConstant()
2593 return new ICmpInst(ICmpInst::ICMP_NE, Builder.CreateOr(Y, C), X); in foldICmpSubConstant()
2599 Instruction *InstCombinerImpl::foldICmpAddConstant(ICmpInst &Cmp, in foldICmpAddConstant()
2616 (Pred == ICmpInst::ICMP_SGT || Pred == ICmpInst::ICMP_SLT)) || in foldICmpAddConstant()
2618 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULT))) { in foldICmpAddConstant()
2627 return new ICmpInst(Pred, X, ConstantInt::get(Ty, NewC)); in foldICmpAddConstant()
2635 return new ICmpInst(ICmpInst::ICMP_SLT, X, ConstantInt::get(Ty, Upper)); in foldICmpAddConstant()
2637 return new ICmpInst(ICmpInst::ICMP_SGE, X, ConstantInt::get(Ty, Lower)); in foldICmpAddConstant()
2640 return new ICmpInst(ICmpInst::ICMP_ULT, X, ConstantInt::get(Ty, Upper)); in foldICmpAddConstant()
2642 return new ICmpInst(ICmpInst::ICMP_UGE, X, ConstantInt::get(Ty, Lower)); in foldICmpAddConstant()
2651 if (Pred == ICmpInst::ICMP_ULT && C.isPowerOf2() && (*C2 & (C - 1)) == 0) in foldICmpAddConstant()
2652 return new ICmpInst(ICmpInst::ICMP_EQ, Builder.CreateAnd(X, -C), in foldICmpAddConstant()
2658 if (Pred == ICmpInst::ICMP_UGT && (C + 1).isPowerOf2() && (*C2 & C) == 0) in foldICmpAddConstant()
2659 return new ICmpInst(ICmpInst::ICMP_NE, Builder.CreateAnd(X, ~C), in foldICmpAddConstant()
2676 ICmpInst::Predicate PredA; in matchThreeWayIntCompare()
2678 !ICmpInst::isEquality(PredA)) in matchThreeWayIntCompare()
2683 if (PredA == ICmpInst::ICMP_NE) in matchThreeWayIntCompare()
2687 ICmpInst::Predicate PredB; in matchThreeWayIntCompare()
2697 PredB = ICmpInst::getSwappedPredicate(PredB); in matchThreeWayIntCompare()
2702 if (PredB == ICmpInst::ICMP_SGT && isa<Constant>(RHS2)) { in matchThreeWayIntCompare()
2709 assert(FlippedStrictness->first == ICmpInst::ICMP_SGE && "Sanity check"); in matchThreeWayIntCompare()
2713 PredB = ICmpInst::ICMP_SLT; in matchThreeWayIntCompare()
2715 return PredB == ICmpInst::ICMP_SLT && RHS == RHS2; in matchThreeWayIntCompare()
2718 Instruction *InstCombinerImpl::foldICmpSelectConstant(ICmpInst &Cmp, in foldICmpSelectConstant()
2755 Cond = Builder.CreateOr(Cond, Builder.CreateICmp(ICmpInst::ICMP_SLT, in foldICmpSelectConstant()
2758 Cond = Builder.CreateOr(Cond, Builder.CreateICmp(ICmpInst::ICMP_EQ, in foldICmpSelectConstant()
2761 Cond = Builder.CreateOr(Cond, Builder.CreateICmp(ICmpInst::ICMP_SGT, in foldICmpSelectConstant()
2769 static Instruction *foldICmpBitCast(ICmpInst &Cmp, in foldICmpBitCast()
2775 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBitCast()
2789 if ((Pred == ICmpInst::ICMP_EQ || Pred == ICmpInst::ICMP_SLT || in foldICmpBitCast()
2790 Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT) && in foldICmpBitCast()
2792 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
2795 if (Pred == ICmpInst::ICMP_SLT && match(Op1, m_One())) in foldICmpBitCast()
2796 return new ICmpInst(Pred, X, ConstantInt::get(X->getType(), 1)); in foldICmpBitCast()
2799 if (Pred == ICmpInst::ICMP_SGT && match(Op1, m_AllOnes())) in foldICmpBitCast()
2800 return new ICmpInst(Pred, X, in foldICmpBitCast()
2809 return new ICmpInst(Pred, X, ConstantInt::getNullValue(X->getType())); in foldICmpBitCast()
2834 return new ICmpInst(ICmpInst::ICMP_SLT, NewBitcast, in foldICmpBitCast()
2837 return new ICmpInst(ICmpInst::ICMP_SGT, NewBitcast, in foldICmpBitCast()
2854 return new ICmpInst(Pred, BCSrcOp, Op1); in foldICmpBitCast()
2886 return new ICmpInst(Pred, Extract, NewC); in foldICmpBitCast()
2895 Instruction *InstCombinerImpl::foldICmpInstWithConstant(ICmpInst &Cmp) { in foldICmpInstWithConstant()
2981 ICmpInst &Cmp, BinaryOperator *BO, const APInt &C) { in foldICmpBinOpEqualityWithConstant()
2987 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpBinOpEqualityWithConstant()
2988 bool isICMP_NE = Pred == ICmpInst::ICMP_NE; in foldICmpBinOpEqualityWithConstant()
2999 return new ICmpInst(Pred, NewRem, in foldICmpBinOpEqualityWithConstant()
3008 return new ICmpInst(Pred, BOp0, ConstantExpr::getSub(RHS, BOC)); in foldICmpBinOpEqualityWithConstant()
3013 return new ICmpInst(Pred, BOp0, NegVal); in foldICmpBinOpEqualityWithConstant()
3015 return new ICmpInst(Pred, NegVal, BOp1); in foldICmpBinOpEqualityWithConstant()
3019 return new ICmpInst(Pred, BOp0, Neg); in foldICmpBinOpEqualityWithConstant()
3029 return new ICmpInst(Pred, BOp0, ConstantExpr::getXor(RHS, BOC)); in foldICmpBinOpEqualityWithConstant()
3032 return new ICmpInst(Pred, BOp0, BOp1); in foldICmpBinOpEqualityWithConstant()
3042 return new ICmpInst(Pred, BOp1, ConstantExpr::getSub(BOC, RHS)); in foldICmpBinOpEqualityWithConstant()
3045 return new ICmpInst(Pred, BOp0, BOp1); in foldICmpBinOpEqualityWithConstant()
3057 return new ICmpInst(Pred, And, NotBOC); in foldICmpBinOpEqualityWithConstant()
3066 return new ICmpInst(isICMP_NE ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_NE, in foldICmpBinOpEqualityWithConstant()
3074 auto NewPred = isICMP_NE ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_UGT; in foldICmpBinOpEqualityWithConstant()
3075 return new ICmpInst(NewPred, BOp1, BOp0); in foldICmpBinOpEqualityWithConstant()
3086 ICmpInst &Cmp, IntrinsicInst *II, const APInt &C) { in foldICmpEqIntrinsicWithConstant()
3094 return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3100 return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3107 return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3121 return new ICmpInst(Cmp.getPredicate(), in foldICmpEqIntrinsicWithConstant()
3133 return new ICmpInst(Cmp.getPredicate(), II->getArgOperand(0), in foldICmpEqIntrinsicWithConstant()
3143 return new ICmpInst(Cmp.getPredicate(), Or, Constant::getNullValue(Ty)); in foldICmpEqIntrinsicWithConstant()
3151 ICmpInst::Predicate NewPred = Cmp.getPredicate() == ICmpInst::ICMP_EQ in foldICmpEqIntrinsicWithConstant()
3152 ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_UGT; in foldICmpEqIntrinsicWithConstant()
3153 return new ICmpInst(NewPred, II->getArgOperand(0), II->getArgOperand(1)); in foldICmpEqIntrinsicWithConstant()
3165 Instruction *InstCombinerImpl::foldICmpIntrinsicWithConstant(ICmpInst &Cmp, in foldICmpIntrinsicWithConstant()
3173 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpIntrinsicWithConstant()
3178 if (C == BitWidth - 1 && Pred == ICmpInst::ICMP_UGT) in foldICmpIntrinsicWithConstant()
3179 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_EQ, X, in foldICmpIntrinsicWithConstant()
3182 if (C == BitWidth && Pred == ICmpInst::ICMP_ULT) in foldICmpIntrinsicWithConstant()
3183 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_NE, X, in foldICmpIntrinsicWithConstant()
3189 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
3192 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_ULT, in foldICmpIntrinsicWithConstant()
3197 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
3200 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_UGT, in foldICmpIntrinsicWithConstant()
3211 if (Pred == ICmpInst::ICMP_UGT && C.ult(BitWidth)) { in foldICmpIntrinsicWithConstant()
3213 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_EQ, in foldICmpIntrinsicWithConstant()
3219 if (Pred == ICmpInst::ICMP_ULT && C.uge(1) && C.ule(BitWidth)) { in foldICmpIntrinsicWithConstant()
3221 return CmpInst::Create(Instruction::ICmp, ICmpInst::ICMP_NE, in foldICmpIntrinsicWithConstant()
3235 Instruction *InstCombinerImpl::foldICmpInstWithConstantNotInt(ICmpInst &I) { in foldICmpInstWithConstantNotInt()
3247 return new ICmpInst( in foldICmpInstWithConstantNotInt()
3311 return new ICmpInst( in foldICmpInstWithConstantNotInt()
3345 static Value *foldICmpWithLowBitMaskedVal(ICmpInst &I, in foldICmpWithLowBitMaskedVal()
3347 ICmpInst::Predicate SrcPred; in foldICmpWithLowBitMaskedVal()
3360 ICmpInst::Predicate DstPred; in foldICmpWithLowBitMaskedVal()
3362 case ICmpInst::Predicate::ICMP_EQ: in foldICmpWithLowBitMaskedVal()
3364 DstPred = ICmpInst::Predicate::ICMP_ULE; in foldICmpWithLowBitMaskedVal()
3366 case ICmpInst::Predicate::ICMP_NE: in foldICmpWithLowBitMaskedVal()
3368 DstPred = ICmpInst::Predicate::ICMP_UGT; in foldICmpWithLowBitMaskedVal()
3370 case ICmpInst::Predicate::ICMP_ULT: in foldICmpWithLowBitMaskedVal()
3373 DstPred = ICmpInst::Predicate::ICMP_UGT; in foldICmpWithLowBitMaskedVal()
3375 case ICmpInst::Predicate::ICMP_UGE: in foldICmpWithLowBitMaskedVal()
3378 DstPred = ICmpInst::Predicate::ICMP_ULE; in foldICmpWithLowBitMaskedVal()
3380 case ICmpInst::Predicate::ICMP_SLT: in foldICmpWithLowBitMaskedVal()
3387 DstPred = ICmpInst::Predicate::ICMP_SGT; in foldICmpWithLowBitMaskedVal()
3389 case ICmpInst::Predicate::ICMP_SGE: in foldICmpWithLowBitMaskedVal()
3396 DstPred = ICmpInst::Predicate::ICMP_SLE; in foldICmpWithLowBitMaskedVal()
3398 case ICmpInst::Predicate::ICMP_SGT: in foldICmpWithLowBitMaskedVal()
3399 case ICmpInst::Predicate::ICMP_SLE: in foldICmpWithLowBitMaskedVal()
3401 case ICmpInst::Predicate::ICMP_UGT: in foldICmpWithLowBitMaskedVal()
3402 case ICmpInst::Predicate::ICMP_ULE: in foldICmpWithLowBitMaskedVal()
3439 foldICmpWithTruncSignExtendedVal(ICmpInst &I, in foldICmpWithTruncSignExtendedVal()
3441 ICmpInst::Predicate SrcPred; in foldICmpWithTruncSignExtendedVal()
3463 ICmpInst::Predicate DstPred; in foldICmpWithTruncSignExtendedVal()
3465 case ICmpInst::Predicate::ICMP_EQ: in foldICmpWithTruncSignExtendedVal()
3469 DstPred = ICmpInst::Predicate::ICMP_ULT; in foldICmpWithTruncSignExtendedVal()
3471 case ICmpInst::Predicate::ICMP_NE: in foldICmpWithTruncSignExtendedVal()
3475 DstPred = ICmpInst::Predicate::ICMP_UGE; in foldICmpWithTruncSignExtendedVal()
3513 foldShiftIntoShiftInAnotherHandOfAndInICmp(ICmpInst &I, const SimplifyQuery SQ, in foldShiftIntoShiftInAnotherHandOfAndInICmp()
3609 m_SpecificInt_ICMP(ICmpInst::Predicate::ICMP_ULT, in foldShiftIntoShiftInAnotherHandOfAndInICmp()
3681 Value *InstCombinerImpl::foldUnsignedMultiplicationOverflowCheck(ICmpInst &I) { in foldUnsignedMultiplicationOverflowCheck()
3682 ICmpInst::Predicate Pred; in foldUnsignedMultiplicationOverflowCheck()
3694 case ICmpInst::Predicate::ICMP_ULT: in foldUnsignedMultiplicationOverflowCheck()
3697 case ICmpInst::Predicate::ICMP_UGE: in foldUnsignedMultiplicationOverflowCheck()
3710 NeedNegation = Pred == ICmpInst::Predicate::ICMP_EQ; in foldUnsignedMultiplicationOverflowCheck()
3743 static Instruction *foldICmpXNegX(ICmpInst &I) { in foldICmpXNegX()
3749 if (ICmpInst::isSigned(Pred)) in foldICmpXNegX()
3750 Pred = ICmpInst::getSwappedPredicate(Pred); in foldICmpXNegX()
3751 else if (ICmpInst::isUnsigned(Pred)) in foldICmpXNegX()
3752 Pred = ICmpInst::getSignedPredicate(Pred); in foldICmpXNegX()
3755 return ICmpInst::Create(Instruction::ICmp, Pred, X, in foldICmpXNegX()
3763 Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I, in foldICmpBinOp()
3783 (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
3784 return new ICmpInst(Pred, Builder.CreateNot(Op1), X); in foldICmpBinOp()
3787 (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
3788 return new ICmpInst(Pred, X, Builder.CreateNot(Op0)); in foldICmpBinOp()
3793 ICmpInst::isEquality(Pred) || in foldICmpBinOp()
3798 ICmpInst::isEquality(Pred) || in foldICmpBinOp()
3817 return new ICmpInst(Pred, A == Op1 ? B : A, in foldICmpBinOp()
3823 return new ICmpInst(Pred, Constant::getNullValue(Op0->getType()), in foldICmpBinOp()
3849 return new ICmpInst(Pred, Y, Z); in foldICmpBinOp()
3855 return new ICmpInst(CmpInst::ICMP_SLE, A, Op1); in foldICmpBinOp()
3860 return new ICmpInst(CmpInst::ICMP_SGT, A, Op1); in foldICmpBinOp()
3864 return new ICmpInst(CmpInst::ICMP_SLT, A, Op1); in foldICmpBinOp()
3868 return new ICmpInst(CmpInst::ICMP_SGE, A, Op1); in foldICmpBinOp()
3873 return new ICmpInst(CmpInst::ICMP_SGE, Op0, C); in foldICmpBinOp()
3878 return new ICmpInst(CmpInst::ICMP_SLT, Op0, C); in foldICmpBinOp()
3882 return new ICmpInst(CmpInst::ICMP_SGT, Op0, C); in foldICmpBinOp()
3886 return new ICmpInst(CmpInst::ICMP_SLE, Op0, C); in foldICmpBinOp()
3899 return new ICmpInst(CmpInst::ICMP_ULT, A, Op1); in foldICmpBinOp()
3903 return new ICmpInst(CmpInst::ICMP_UGE, A, Op1); in foldICmpBinOp()
3907 return new ICmpInst(CmpInst::ICMP_UGT, Op0, C); in foldICmpBinOp()
3911 return new ICmpInst(CmpInst::ICMP_ULE, Op0, C); in foldICmpBinOp()
3932 return new ICmpInst(Pred, NewAdd, C); in foldICmpBinOp()
3936 return new ICmpInst(Pred, A, NewAdd); in foldICmpBinOp()
3958 return new ICmpInst(Pred, Constant::getNullValue(Op1->getType()), B); in foldICmpBinOp()
3961 return new ICmpInst(Pred, D, Constant::getNullValue(Op0->getType())); in foldICmpBinOp()
3965 if (A == Op1 && (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE)) in foldICmpBinOp()
3966 return new ICmpInst(Pred, B, A); in foldICmpBinOp()
3968 if (C == Op0 && (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)) in foldICmpBinOp()
3969 return new ICmpInst(Pred, C, D); in foldICmpBinOp()
3971 if (A == Op1 && (Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_ULT) && in foldICmpBinOp()
3973 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), B, A); in foldICmpBinOp()
3975 if (C == Op0 && (Pred == ICmpInst::ICMP_ULE || Pred == ICmpInst::ICMP_UGT) && in foldICmpBinOp()
3977 return new ICmpInst(CmpInst::getFlippedStrictnessPredicate(Pred), C, D); in foldICmpBinOp()
3981 return new ICmpInst(Pred, A, C); in foldICmpBinOp()
3985 return new ICmpInst(Pred, D, B); in foldICmpBinOp()
3988 if (NoOp0WrapProblem && ICmpInst::isSigned(Pred)) { in foldICmpBinOp()
3993 return new ICmpInst(I.getSwappedPredicate(), X, in foldICmpBinOp()
4007 return new ICmpInst(Pred, X, Y); in foldICmpBinOp()
4021 switch (SRem == BO0 ? ICmpInst::getSwappedPredicate(Pred) : Pred) { in foldICmpBinOp()
4024 case ICmpInst::ICMP_EQ: in foldICmpBinOp()
4026 case ICmpInst::ICMP_NE: in foldICmpBinOp()
4028 case ICmpInst::ICMP_SGT: in foldICmpBinOp()
4029 case ICmpInst::ICMP_SGE: in foldICmpBinOp()
4030 return new ICmpInst(ICmpInst::ICMP_SGT, SRem->getOperand(1), in foldICmpBinOp()
4032 case ICmpInst::ICMP_SLT: in foldICmpBinOp()
4033 case ICmpInst::ICMP_SLE: in foldICmpBinOp()
4034 return new ICmpInst(ICmpInst::ICMP_SLT, SRem->getOperand(1), in foldICmpBinOp()
4048 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4054 ICmpInst::Predicate NewPred = I.getFlippedSignednessPredicate(); in foldICmpBinOp()
4055 return new ICmpInst(NewPred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4060 ICmpInst::Predicate NewPred = I.getFlippedSignednessPredicate(); in foldICmpBinOp()
4062 return new ICmpInst(NewPred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4082 return new ICmpInst(Pred, And1, And2); in foldICmpBinOp()
4091 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4096 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4101 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4110 return new ICmpInst(Pred, BO0->getOperand(0), BO1->getOperand(0)); in foldICmpBinOp()
4120 if (match(BO0, BitwiseAnd) && Pred == ICmpInst::ICMP_ULT) { in foldICmpBinOp()
4122 return new ICmpInst(ICmpInst::ICMP_NE, Op1, Zero); in foldICmpBinOp()
4142 static Instruction *foldICmpWithMinMax(ICmpInst &Cmp) { in foldICmpWithMinMax()
4143 ICmpInst::Predicate Pred = Cmp.getPredicate(); in foldICmpWithMinMax()
4161 return new ICmpInst(ICmpInst::ICMP_SLE, X, Y); in foldICmpWithMinMax()
4166 return new ICmpInst(ICmpInst::ICMP_SGT, X, Y); in foldICmpWithMinMax()
4178 return new ICmpInst(ICmpInst::ICMP_SGE, X, Y); in foldICmpWithMinMax()
4183 return new ICmpInst(ICmpInst::ICMP_SLT, X, Y); in foldICmpWithMinMax()
4195 return new ICmpInst(ICmpInst::ICMP_ULE, X, Y); in foldICmpWithMinMax()
4200 return new ICmpInst(ICmpInst::ICMP_UGT, X, Y); in foldICmpWithMinMax()
4212 return new ICmpInst(ICmpInst::ICMP_UGE, X, Y); in foldICmpWithMinMax()
4217 return new ICmpInst(ICmpInst::ICMP_ULT, X, Y); in foldICmpWithMinMax()
4228 Instruction *InstCombinerImpl::foldICmpEquality(ICmpInst &I) { in foldICmpEquality()
4238 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
4248 return new ICmpInst(Pred, A, Xor); in foldICmpEquality()
4253 return new ICmpInst(Pred, B, D); in foldICmpEquality()
4255 return new ICmpInst(Pred, B, C); in foldICmpEquality()
4257 return new ICmpInst(Pred, A, D); in foldICmpEquality()
4259 return new ICmpInst(Pred, A, C); in foldICmpEquality()
4266 return new ICmpInst(Pred, OtherVal, Constant::getNullValue(A->getType())); in foldICmpEquality()
4295 return new ICmpInst(Pred, Op1, Constant::getNullValue(Op1->getType())); in foldICmpEquality()
4309 return new ICmpInst(Pred, A, Builder.CreateTrunc(B, A->getType())); in foldICmpEquality()
4321 ICmpInst::Predicate NewPred = in foldICmpEquality()
4322 Pred == ICmpInst::ICMP_NE ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_ULT; in foldICmpEquality()
4325 return new ICmpInst(NewPred, Xor, Builder.getInt(CmpVal)); in foldICmpEquality()
4339 return new ICmpInst(Pred, And, Constant::getNullValue(Cst1->getType())); in foldICmpEquality()
4363 return new ICmpInst(Pred, Mask, Builder.getInt(CmpV)); in foldICmpEquality()
4374 return new ICmpInst(Pred, A, B); in foldICmpEquality()
4395 return Pred == ICmpInst::ICMP_EQ in foldICmpEquality()
4396 ? new ICmpInst(ICmpInst::ICMP_ULT, CtPop, ConstantInt::get(Ty, 2)) in foldICmpEquality()
4397 : new ICmpInst(ICmpInst::ICMP_UGT, CtPop, ConstantInt::get(Ty, 1)); in foldICmpEquality()
4403 static Instruction *foldICmpWithZextOrSext(ICmpInst &ICmp, in foldICmpWithZextOrSext()
4439 return new ICmpInst(ICmp.getPredicate(), X, Y); in foldICmpWithZextOrSext()
4444 return new ICmpInst(ICmp.getPredicate(), X, Y); in foldICmpWithZextOrSext()
4447 return new ICmpInst(ICmp.getUnsignedPredicate(), X, Y); in foldICmpWithZextOrSext()
4465 return new ICmpInst(ICmp.getPredicate(), X, Res1); in foldICmpWithZextOrSext()
4470 return new ICmpInst(ICmp.getPredicate(), X, Res1); in foldICmpWithZextOrSext()
4473 return new ICmpInst(ICmp.getUnsignedPredicate(), X, Res1); in foldICmpWithZextOrSext()
4486 if (ICmp.getPredicate() == ICmpInst::ICMP_ULT) in foldICmpWithZextOrSext()
4487 return new ICmpInst(CmpInst::ICMP_SGT, X, Constant::getAllOnesValue(SrcTy)); in foldICmpWithZextOrSext()
4491 assert(ICmp.getPredicate() == ICmpInst::ICMP_UGT && "ICmp should be folded!"); in foldICmpWithZextOrSext()
4492 return new ICmpInst(CmpInst::ICMP_SLT, X, Constant::getNullValue(SrcTy)); in foldICmpWithZextOrSext()
4496 Instruction *InstCombinerImpl::foldICmpWithCastOp(ICmpInst &ICmp) { in foldICmpWithCastOp()
4533 return new ICmpInst(ICmp.getPredicate(), Op0Src, NewOp1); in foldICmpWithCastOp()
4639 static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal, in processUMulZExtIdiom()
4708 case ICmpInst::ICMP_EQ: in processUMulZExtIdiom()
4709 case ICmpInst::ICMP_NE: in processUMulZExtIdiom()
4727 case ICmpInst::ICMP_UGT: in processUMulZExtIdiom()
4739 case ICmpInst::ICMP_UGE: in processUMulZExtIdiom()
4750 case ICmpInst::ICMP_ULE: in processUMulZExtIdiom()
4762 case ICmpInst::ICMP_ULT: in processUMulZExtIdiom()
4826 case ICmpInst::ICMP_NE: in processUMulZExtIdiom()
4828 case ICmpInst::ICMP_EQ: in processUMulZExtIdiom()
4831 case ICmpInst::ICMP_UGT: in processUMulZExtIdiom()
4832 case ICmpInst::ICMP_UGE: in processUMulZExtIdiom()
4837 case ICmpInst::ICMP_ULT: in processUMulZExtIdiom()
4838 case ICmpInst::ICMP_ULE: in processUMulZExtIdiom()
4857 static APInt getDemandedBitsLHSMask(ICmpInst &I, unsigned BitWidth) { in getDemandedBitsLHSMask()
4873 case ICmpInst::ICMP_UGT: in getDemandedBitsLHSMask()
4878 case ICmpInst::ICMP_ULT: in getDemandedBitsLHSMask()
4951 auto *IC = dyn_cast<ICmpInst>(BI->getCondition()); in isChainSelectCmpBranch()
4998 const ICmpInst *Icmp, in replacedSelectWithOperand()
5001 if (isChainSelectCmpBranch(SI) && Icmp->getPredicate() == ICmpInst::ICMP_EQ) { in replacedSelectWithOperand()
5025 Instruction *InstCombinerImpl::foldICmpUsingKnownBits(ICmpInst &I) { in foldICmpUsingKnownBits()
5028 ICmpInst::Predicate Pred = I.getPredicate(); in foldICmpUsingKnownBits()
5067 return new ICmpInst(Pred, ConstantExpr::getIntegerValue(Ty, Op0Min), Op1); in foldICmpUsingKnownBits()
5069 return new ICmpInst(Pred, Op0, ConstantExpr::getIntegerValue(Ty, Op1Min)); in foldICmpUsingKnownBits()
5076 case ICmpInst::ICMP_EQ: in foldICmpUsingKnownBits()
5077 case ICmpInst::ICMP_NE: { in foldICmpUsingKnownBits()
5104 auto NewPred = ICmpInst::getInversePredicate(Pred); in foldICmpUsingKnownBits()
5105 return new ICmpInst(NewPred, X, CmpC); in foldICmpUsingKnownBits()
5112 return new ICmpInst(NewPred, X, CmpC); in foldICmpUsingKnownBits()
5123 auto NewPred = ICmpInst::getInversePredicate(Pred); in foldICmpUsingKnownBits()
5124 return new ICmpInst(NewPred, X, ConstantInt::get(X->getType(), CmpVal)); in foldICmpUsingKnownBits()
5129 case ICmpInst::ICMP_ULT: { in foldICmpUsingKnownBits()
5135 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); in foldICmpUsingKnownBits()
5141 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, in foldICmpUsingKnownBits()
5146 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, in foldICmpUsingKnownBits()
5151 case ICmpInst::ICMP_UGT: { in foldICmpUsingKnownBits()
5157 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); in foldICmpUsingKnownBits()
5163 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, in foldICmpUsingKnownBits()
5168 return new ICmpInst(ICmpInst::ICMP_NE, Op0, in foldICmpUsingKnownBits()
5173 case ICmpInst::ICMP_SLT: { in foldICmpUsingKnownBits()
5179 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); in foldICmpUsingKnownBits()
5183 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, in foldICmpUsingKnownBits()
5188 case ICmpInst::ICMP_SGT: { in foldICmpUsingKnownBits()
5194 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1); in foldICmpUsingKnownBits()
5198 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, in foldICmpUsingKnownBits()
5203 case ICmpInst::ICMP_SGE: in foldICmpUsingKnownBits()
5210 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1); in foldICmpUsingKnownBits()
5212 case ICmpInst::ICMP_SLE: in foldICmpUsingKnownBits()
5219 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1); in foldICmpUsingKnownBits()
5221 case ICmpInst::ICMP_UGE: in foldICmpUsingKnownBits()
5228 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1); in foldICmpUsingKnownBits()
5230 case ICmpInst::ICMP_ULE: in foldICmpUsingKnownBits()
5237 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1); in foldICmpUsingKnownBits()
5246 return new ICmpInst(I.getUnsignedPredicate(), Op0, Op1); in foldICmpUsingKnownBits()
5254 assert(ICmpInst::isRelational(Pred) && ICmpInst::isIntPredicate(Pred) && in getFlippedStrictnessPredicateAndConstant()
5258 bool IsSigned = ICmpInst::isSigned(Pred); in getFlippedStrictnessPredicateAndConstant()
5260 CmpInst::Predicate UnsignedPred = ICmpInst::getUnsignedPredicate(Pred); in getFlippedStrictnessPredicateAndConstant()
5262 UnsignedPred == ICmpInst::ICMP_ULE || UnsignedPred == ICmpInst::ICMP_UGT; in getFlippedStrictnessPredicateAndConstant()
5319 static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I) { in canonicalizeCmpWithConstant()
5320 ICmpInst::Predicate Pred = I.getPredicate(); in canonicalizeCmpWithConstant()
5321 if (ICmpInst::isEquality(Pred) || !ICmpInst::isIntPredicate(Pred) || in canonicalizeCmpWithConstant()
5336 return new ICmpInst(FlippedStrictness->first, Op0, FlippedStrictness->second); in canonicalizeCmpWithConstant()
5381 static Instruction *canonicalizeICmpBool(ICmpInst &I, in canonicalizeICmpBool()
5412 case ICmpInst::ICMP_EQ: in canonicalizeICmpBool()
5416 case ICmpInst::ICMP_NE: in canonicalizeICmpBool()
5420 case ICmpInst::ICMP_UGT: in canonicalizeICmpBool()
5424 case ICmpInst::ICMP_ULT: in canonicalizeICmpBool()
5428 case ICmpInst::ICMP_SGT: in canonicalizeICmpBool()
5432 case ICmpInst::ICMP_SLT: in canonicalizeICmpBool()
5436 case ICmpInst::ICMP_UGE: in canonicalizeICmpBool()
5440 case ICmpInst::ICMP_ULE: in canonicalizeICmpBool()
5444 case ICmpInst::ICMP_SGE: in canonicalizeICmpBool()
5448 case ICmpInst::ICMP_SLE: in canonicalizeICmpBool()
5460 static Instruction *foldICmpWithHighBitMask(ICmpInst &Cmp, in foldICmpWithHighBitMask()
5462 ICmpInst::Predicate Pred, NewPred; in foldICmpWithHighBitMask()
5467 case ICmpInst::ICMP_ULE: in foldICmpWithHighBitMask()
5468 NewPred = ICmpInst::ICMP_NE; in foldICmpWithHighBitMask()
5470 case ICmpInst::ICMP_UGT: in foldICmpWithHighBitMask()
5471 NewPred = ICmpInst::ICMP_EQ; in foldICmpWithHighBitMask()
5486 case ICmpInst::ICMP_ULT: in foldICmpWithHighBitMask()
5487 NewPred = ICmpInst::ICMP_NE; in foldICmpWithHighBitMask()
5489 case ICmpInst::ICMP_UGE: in foldICmpWithHighBitMask()
5490 NewPred = ICmpInst::ICMP_EQ; in foldICmpWithHighBitMask()
5549 static Instruction *foldICmpOfUAddOv(ICmpInst &I) { in foldICmpOfUAddOv()
5558 ((Pred == ICmpInst::ICMP_ULT && (Op1 == A || Op1 == B)) || in foldICmpOfUAddOv()
5559 (Pred == ICmpInst::ICMP_EQ && match(Op1, m_ZeroInt()) && in foldICmpOfUAddOv()
5561 (Pred == ICmpInst::ICMP_NE && match(Op1, m_AllOnes()) && in foldICmpOfUAddOv()
5568 Pred == ICmpInst::ICMP_UGT && (Op0 == A || Op0 == B)) in foldICmpOfUAddOv()
5577 Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) { in visitICmpInst()
5599 if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) { in visitICmpInst()
5662 ICmpInst::Predicate Pred = I.getPredicate(); in visitICmpInst()
5666 if (Pred == ICmpInst::ICMP_UGT && C->isMaxSignedValue()) { in visitICmpInst()
5668 return new ICmpInst(ICmpInst::ICMP_SLT, Op0, Zero); in visitICmpInst()
5672 if (Pred == ICmpInst::ICMP_ULT && C->isMinSignedValue()) { in visitICmpInst()
5674 return new ICmpInst(ICmpInst::ICMP_SGT, Op0, AllOnes); in visitICmpInst()
5695 ICmpInst::getSwappedPredicate(I.getPredicate()), I)) in visitICmpInst()
5727 return new ICmpInst(I.getInversePredicate(), Builder.CreateAnd(A, B), in visitICmpInst()
5734 return new ICmpInst(I.getPredicate(), B, A); in visitICmpInst()
5738 return new ICmpInst(I.getSwappedPredicate(), A, in visitICmpInst()
5785 if (I.getPredicate() == ICmpInst::ICMP_EQ) in visitICmpInst()
5885 ICmpInst::Predicate Pred; in foldFCmpIntToFPConst()
5890 Pred = ICmpInst::ICMP_EQ; in foldFCmpIntToFPConst()
5894 Pred = LHSUnsigned ? ICmpInst::ICMP_UGT : ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
5898 Pred = LHSUnsigned ? ICmpInst::ICMP_UGE : ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
5902 Pred = LHSUnsigned ? ICmpInst::ICMP_ULT : ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
5906 Pred = LHSUnsigned ? ICmpInst::ICMP_ULE : ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
5910 Pred = ICmpInst::ICMP_NE; in foldFCmpIntToFPConst()
5931 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SLT || in foldFCmpIntToFPConst()
5932 Pred == ICmpInst::ICMP_SLE) in foldFCmpIntToFPConst()
5943 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_ULT || in foldFCmpIntToFPConst()
5944 Pred == ICmpInst::ICMP_ULE) in foldFCmpIntToFPConst()
5956 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_SGT || in foldFCmpIntToFPConst()
5957 Pred == ICmpInst::ICMP_SGE) in foldFCmpIntToFPConst()
5967 if (Pred == ICmpInst::ICMP_NE || Pred == ICmpInst::ICMP_UGT || in foldFCmpIntToFPConst()
5968 Pred == ICmpInst::ICMP_UGE) in foldFCmpIntToFPConst()
5991 case ICmpInst::ICMP_NE: // (float)int != 4.4 --> true in foldFCmpIntToFPConst()
5993 case ICmpInst::ICMP_EQ: // (float)int == 4.4 --> false in foldFCmpIntToFPConst()
5995 case ICmpInst::ICMP_ULE: in foldFCmpIntToFPConst()
6001 case ICmpInst::ICMP_SLE: in foldFCmpIntToFPConst()
6005 Pred = ICmpInst::ICMP_SLT; in foldFCmpIntToFPConst()
6007 case ICmpInst::ICMP_ULT: in foldFCmpIntToFPConst()
6012 Pred = ICmpInst::ICMP_ULE; in foldFCmpIntToFPConst()
6014 case ICmpInst::ICMP_SLT: in foldFCmpIntToFPConst()
6018 Pred = ICmpInst::ICMP_SLE; in foldFCmpIntToFPConst()
6020 case ICmpInst::ICMP_UGT: in foldFCmpIntToFPConst()
6026 case ICmpInst::ICMP_SGT: in foldFCmpIntToFPConst()
6030 Pred = ICmpInst::ICMP_SGE; in foldFCmpIntToFPConst()
6032 case ICmpInst::ICMP_UGE: in foldFCmpIntToFPConst()
6037 Pred = ICmpInst::ICMP_UGT; in foldFCmpIntToFPConst()
6039 case ICmpInst::ICMP_SGE: in foldFCmpIntToFPConst()
6043 Pred = ICmpInst::ICMP_SGT; in foldFCmpIntToFPConst()
6051 return new ICmpInst(Pred, LHSI->getOperand(0), RHSInt); in foldFCmpIntToFPConst()