Home | History | Annotate | Download | only in InstCombine

Lines Matching refs:ICI

231                              CmpInst &ICI, ConstantInt *AndCst) {
303 Constant *CompareRHS = cast<Constant>(ICI.getOperand(1));
316 Constant *C = ConstantFoldCompareInstOperands(ICI.getPredicate(), Elt,
407 return ReplaceInstUsesWith(ICI, Builder->getFalse());
427 return ReplaceInstUsesWith(ICI, Builder->getTrue());
741 Instruction *InstCombiner::FoldICmpAddOpCst(Instruction &ICI,
790 Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
792 ConstantInt *CmpRHS = cast<ConstantInt>(ICI.getOperand(1));
804 if (!ICI.isEquality() && DivIsSigned != ICI.isSigned())
812 ICI.setOperand(0, DivI->getOperand(0)); // X/1 == X.
813 return &ICI;
829 ICmpInst::Predicate Pred = ICI.getPredicate();
907 return ReplaceInstUsesWith(ICI, Builder->getFalse());
914 return ReplaceInstUsesWith(ICI, InsertRangeTest(X, LoBound, HiBound,
918 return ReplaceInstUsesWith(ICI, Builder->getTrue());
925 return ReplaceInstUsesWith(ICI, InsertRangeTest(X, LoBound, HiBound,
930 return ReplaceInstUsesWith(ICI, Builder->getTrue());
932 return ReplaceInstUsesWith(ICI, Builder->getFalse());
937 return ReplaceInstUsesWith(ICI, Builder->getFalse());
939 return ReplaceInstUsesWith(ICI, Builder->getTrue());
947 Instruction *InstCombiner::FoldICmpShrCst(ICmpInst &ICI, BinaryOperator *Shr,
949 const APInt &CmpRHSV = cast<ConstantInt>(ICI.getOperand(1))->getValue();
959 if (!ICI.isEquality()) {
962 if (ICI.isSigned() != (Shr->getOpcode() == Instruction::AShr))
983 ICI.setOperand(0, Tmp);
988 return &ICI;
994 Instruction *Res = FoldICmpDivCst(ICI, TheDiv, cast<ConstantInt>(DivCst));
1010 bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
1012 return ReplaceInstUsesWith(ICI, Cst);
1019 return new ICmpInst(ICI.getPredicate(), Shr->getOperand(0), ShiftedCmpRHS);
1028 return new ICmpInst(ICI.getPredicate(), And, ShiftedCmpRHS);
1141 Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
1148 if (ICI.isEquality() && LHSI->hasOneUse()) {
1154 computeKnownBits(LHSI->getOperand(0), KnownZero, KnownOne, 0, &ICI);
1161 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1171 if ((ICI.getPredicate() == ICmpInst::ICMP_SLT && RHSV == 0) ||
1172 (ICI.getPredicate() == ICmpInst::ICMP_SGT && RHSV.isAllOnesValue())) {
1178 ICI.setOperand(0, CompareVal);
1180 return &ICI;
1184 bool isTrueIfPositive = ICI.getPredicate() == ICmpInst::ICMP_SGT;
1199 if (!ICI.isEquality() && XorCst->getValue().isSignBit()) {
1201 ICmpInst::Predicate Pred = ICI.isSigned()
1202 ? ICI.getUnsignedPredicate()
1203 : ICI.getSignedPredicate();
1209 if (!ICI.isEquality() && XorCst->isMaxValue(true)) {
1211 ICmpInst::Predicate Pred = ICI.isSigned()
1212 ? ICI.getUnsignedPredicate()
1213 : ICI.getSignedPredicate();
1214 Pred = ICI.getSwappedPredicate(Pred);
1222 if (ICI.getPredicate() == ICmpInst::ICMP_UGT &&
1228 if (ICI.getPredicate() == ICmpInst::ICMP_ULT &&
1246 if (ICI.isEquality() ||
1252 return new ICmpInst(ICI.getPredicate(), NewAnd,
1263 if (ICI.isEquality() && RHSV.getActiveBits() <= Ty->getBitWidth()) {
1268 return new ICmpInst(ICI.getPredicate(), NewAnd,
1300 if (!ICI.isSigned() || (!AndCst->isNegative() && !RHS->isNegative()))
1308 if (!ICI.isSigned())
1334 if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
1335 return ReplaceInstUsesWith(ICI, Builder->getFalse());
1336 if (ICI.getPredicate() == ICmpInst::ICMP_NE)
1337 return ReplaceInstUsesWith(ICI, Builder->getTrue());
1339 ICI.setOperand(1, NewCst);
1348 return &ICI;
1357 ICI.isEquality() && !Shift->isArithmeticShift() &&
1372 ICI.setOperand(0, NewAnd);
1373 return &ICI;
1382 if (!ICI.isSigned() && RHSV == 0) {
1410 ICI.setOperand(0, NewAnd);
1411 return &ICI;
1420 if (ICI.getPredicate() == ICmpInst::ICMP_UGT) {
1437 if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV,ICI, C))
1445 if (ICI.isEquality() && RHS == LHSI->getOperand(1) && (-RHSV).isPowerOf2())
1447 ICI.getPredicate() == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_UGT
1453 if (!ICI.isEquality() || !RHS->isNullValue() || !LHSI->hasOneUse())
1459 Value *ICIP = Builder->CreateICmp(ICI.getPredicate(), P,
1461 Value *ICIQ = Builder->CreateICmp(ICI.getPredicate(), Q,
1464 if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
1479 ICmpInst::Predicate pred = ICI.getPredicate();
1498 ICmpInst::Predicate Pred = ICI.getPredicate();
1499 if (ICI.isUnsigned()) {
1523 } else if (ICI.isSigned()) {
1547 } else if (ICI.isEquality()) {
1562 if (ICI.isEquality()) {
1569 bool IsICMP_NE = ICI
1571 return ReplaceInstUsesWith(ICI, Cst);
1577 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1583 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1594 return new ICmpInst(ICI.getPredicate(), And,
1601 ICmpInst::Predicate pred = ICI.getPredicate();
1611 isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) {
1631 Type *NTy = IntegerType::get(ICI.getContext(), TypeBits - Amt);
1636 return new ICmpInst(ICI.getPredicate(),
1649 if (Instruction *Res = FoldICmpShrCst(ICI, BO, ShAmt))
1654 if (ICI.isEquality() && BO->isExact() && BO->hasOneUse()) {
1656 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), RHS);
1670 if (Instruction *R = FoldICmpDivCst(ICI, cast<BinaryOperator>(LHSI),
1683 if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
1692 if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
1701 if (!ICI.isEquality()) {
1706 ConstantRange CR = ICI.makeConstantRange(ICI.getPredicate(), RHSV)
1709 if (ICI.isSigned()) {
1730 if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
1739 if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
1749 if (ICI.isEquality()) {
1750 bool isICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
1764 return new ICmpInst(ICI.getPredicate(), NewRem,
1773 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1781 return new ICmpInst(ICI.getPredicate(), BOp0, NegVal);
1783 return new ICmpInst(ICI.getPredicate(), NegVal, BOp1);
1787 return new ICmpInst(ICI.getPredicate(), BOp0, Neg);
1795 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1799 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1807 return new ICmpInst(ICI.getPredicate(), BO->getOperand(1),
1811 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1821 return ReplaceInstUsesWith(ICI, Builder->getInt1(isICMP_NE));
1830 return ReplaceInstUsesWith(ICI, Builder->getInt1(isICMP_NE));
1868 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1880 ICI.setOperand(0, II->getArgOperand(0));
1881 ICI.setOperand(1, Builder->getInt(RHSV.byteSwap()));
1882 return &ICI;
1888 ICI.setOperand(0, II->getArgOperand(0));
1889 ICI.setOperand(1, ConstantInt::get(RHS->getType(), 0));
1890 return &ICI;
1897 ICI.setOperand(0, II->getArgOperand(0));
1898 ICI.setOperand(1, RHS);
1899 return &ICI;
1913 Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
1914 const CastInst *LHSCI = cast<CastInst>(ICI.getOperand(0));
1925 if (PtrToIntOperator *RHSC = dyn_cast<PtrToIntOperator>(ICI.getOperand(1))) {
1934 } else if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1)))
1938 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSOp);
1948 bool isSignedCmp = ICI.isSigned();
1950 if (CastInst *CI = dyn_cast<CastInst>(ICI.getOperand(1))) {
1962 if (ICI.isEquality())
1963 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
1968 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
1971 return new ICmpInst(ICI.getUnsignedPredicate(), LHSCIOp, RHSCIOp);
1975 ConstantInt *CI = dyn_cast<ConstantInt>(ICI.getOperand(1));
1988 if (ICI.isEquality())
1989 return new ICmpInst(ICI.getPredicate(), LHSCIOp, Res1);
1994 return new ICmpInst(ICI.getPredicate(), LHSCIOp, Res1);
1997 return new ICmpInst(ICI.getUnsignedPredicate(), LHSCIOp, Res1);
2014 Value *Result = Builder->CreateICmpSGT(LHSCIOp, NegOne, ICI.getName());
2017 if (ICI.getPredicate() == ICmpInst::ICMP_ULT)
2018 return ReplaceInstUsesWith(ICI, Result);
2020 assert(ICI.getPredicate() == ICmpInst::ICMP_UGT && "ICmp should be folded!");