Lines Matching refs:ICI

221                              CmpInst &ICI, ConstantInt *AndCst) {
298 Constant *CompareRHS = cast<Constant>(ICI.getOperand(1));
311 Constant *C = ConstantFoldCompareInstOperands(ICI.getPredicate(), Elt,
402 return ReplaceInstUsesWith(ICI, Builder->getFalse());
422 return ReplaceInstUsesWith(ICI, Builder->getTrue());
740 Instruction *InstCombiner::FoldICmpAddOpCst(Instruction &ICI,
747 return ReplaceInstUsesWith(ICI, ConstantInt::get(ICI.getType(), isTrue));
752 return ReplaceInstUsesWith(ICI, Builder->getFalse());
756 return ReplaceInstUsesWith(ICI, Builder->getTrue());
804 Instruction *InstCombiner::FoldICmpDivCst(ICmpInst &ICI, BinaryOperator *DivI,
806 ConstantInt *CmpRHS = cast<ConstantInt>(ICI.getOperand(1));
818 if (!ICI.isEquality() && DivIsSigned != ICI.isSigned())
826 ICI.setOperand(0, DivI->getOperand(0)); // X/1 == X.
827 return &ICI;
843 ICmpInst::Predicate Pred = ICI.getPredicate();
921 return ReplaceInstUsesWith(ICI, Builder->getFalse());
928 return ReplaceInstUsesWith(ICI, InsertRangeTest(X, LoBound, HiBound,
932 return ReplaceInstUsesWith(ICI, Builder->getTrue());
939 return ReplaceInstUsesWith(ICI, InsertRangeTest(X, LoBound, HiBound,
944 return ReplaceInstUsesWith(ICI, Builder->getTrue());
946 return ReplaceInstUsesWith(ICI, Builder->getFalse());
951 return ReplaceInstUsesWith(ICI, Builder->getFalse());
953 return ReplaceInstUsesWith(ICI, Builder->getTrue());
961 Instruction *InstCombiner::FoldICmpShrCst(ICmpInst &ICI, BinaryOperator *Shr,
963 const APInt &CmpRHSV = cast<ConstantInt>(ICI.getOperand(1))->getValue();
973 if (!ICI.isEquality()) {
976 if (ICI.isSigned() != (Shr->getOpcode() == Instruction::AShr))
997 ICI.setOperand(0, Tmp);
1002 return &ICI;
1008 Instruction *Res = FoldICmpDivCst(ICI, TheDiv, cast<ConstantInt>(DivCst));
1024 bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
1026 return ReplaceInstUsesWith(ICI, Cst);
1033 return new ICmpInst(ICI.getPredicate(), Shr->getOperand(0), ShiftedCmpRHS);
1042 return new ICmpInst(ICI.getPredicate(), And, ShiftedCmpRHS);
1050 Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
1057 if (ICI.isEquality() && LHSI->hasOneUse()) {
1070 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1080 if ((ICI.getPredicate() == ICmpInst::ICMP_SLT && RHSV == 0) ||
1081 (ICI.getPredicate() == ICmpInst::ICMP_SGT && RHSV.isAllOnesValue())) {
1087 ICI.setOperand(0, CompareVal);
1089 return &ICI;
1093 bool isTrueIfPositive = ICI.getPredicate() == ICmpInst::ICMP_SGT;
1108 if (!ICI.isEquality() && XorCst->getValue().isSignBit()) {
1110 ICmpInst::Predicate Pred = ICI.isSigned()
1111 ? ICI.getUnsignedPredicate()
1112 : ICI.getSignedPredicate();
1118 if (!ICI.isEquality() && XorCst->isMaxValue(true)) {
1120 ICmpInst::Predicate Pred = ICI.isSigned()
1121 ? ICI.getUnsignedPredicate()
1122 : ICI.getSignedPredicate();
1123 Pred = ICI.getSwappedPredicate(Pred);
1131 if (ICI.getPredicate() == ICmpInst::ICMP_UGT &&
1137 if (ICI.getPredicate() == ICmpInst::ICMP_ULT &&
1155 if (ICI.isEquality() ||
1161 return new ICmpInst(ICI.getPredicate(), NewAnd,
1172 if (ICI.isEquality() && RHSV.getActiveBits() <= Ty->getBitWidth()) {
1177 return new ICmpInst(ICI.getPredicate(), NewAnd,
1209 if (!ICI.isSigned() || (!AndCst->isNegative() && !RHS->isNegative()))
1217 if (!ICI.isSigned())
1243 if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
1244 return ReplaceInstUsesWith(ICI, Builder->getFalse());
1245 if (ICI.getPredicate() == ICmpInst::ICMP_NE)
1246 return ReplaceInstUsesWith(ICI, Builder->getTrue());
1248 ICI.setOperand(1, NewCst);
1257 return &ICI;
1266 ICI.isEquality() && !Shift->isArithmeticShift() &&
1281 ICI.setOperand(0, NewAnd);
1282 return &ICI;
1287 if (ICI.getPredicate() == ICmpInst::ICMP_UGT) {
1304 if (Instruction *Res = FoldCmpLoadFromIndexedGlobal(GEP, GV,ICI, C))
1312 if (ICI.isEquality() && RHS == LHSI->getOperand(1) && (-RHSV).isPowerOf2())
1314 ICI.getPredicate() == ICmpInst::ICMP_EQ ? ICmpInst::ICMP_UGT
1320 if (!ICI.isEquality() || !RHS->isNullValue() || !LHSI->hasOneUse())
1326 Value *ICIP = Builder->CreateICmp(ICI.getPredicate(), P,
1328 Value *ICIQ = Builder->CreateICmp(ICI.getPredicate(), Q,
1331 if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
1346 ICmpInst::Predicate pred = ICI.getPredicate();
1365 ICmpInst::Predicate Pred = ICI.getPredicate();
1366 if (ICI.isUnsigned()) {
1387 return ReplaceInstUsesWith(ICI, Builder->getFalse());
1389 return ReplaceInstUsesWith(ICI, Builder->getTrue());
1396 } else if (ICI.isSigned()) {
1420 } else if (ICI.isEquality()) {
1426 ICI, Pred == ICmpInst::ICMP_EQ ? Builder->getFalse()
1439 if (ICI.isEquality()) {
1446 bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
1448 return ReplaceInstUsesWith(ICI, Cst);
1454 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1460 return new ICmpInst(ICI.getPredicate(), LHSI->getOperand(0),
1471 return new ICmpInst(ICI.getPredicate(), And,
1478 ICmpInst::Predicate pred = ICI.getPredicate();
1488 isSignBitCheck(ICI.getPredicate(), RHS, TrueIfSigned)) {
1508 Type *NTy = IntegerType::get(ICI.getContext(), TypeBits - Amt);
1513 return new ICmpInst(ICI.getPredicate(),
1526 if (Instruction *Res = FoldICmpShrCst(ICI, BO, ShAmt))
1531 if (ICI.isEquality() && BO->isExact() && BO->hasOneUse()) {
1533 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0), RHS);
1547 if (Instruction *R = FoldICmpDivCst(ICI, cast<BinaryOperator>(LHSI),
1560 if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
1569 if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
1578 if (!ICI.isEquality()) {
1583 ConstantRange CR = ICI.makeConstantRange(ICI.getPredicate(), RHSV)
1586 if (ICI.isSigned()) {
1607 if (ICI.getPredicate() == ICmpInst::ICMP_ULT && LHSI->hasOneUse() &&
1616 if (ICI.getPredicate() == ICmpInst::ICMP_UGT && LHSI->hasOneUse() &&
1626 if (ICI.isEquality()) {
1627 bool isICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
1641 return new ICmpInst(ICI.getPredicate(), NewRem,
1650 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1658 return new ICmpInst(ICI.getPredicate(), BOp0, NegVal);
1660 return new ICmpInst(ICI.getPredicate(), NegVal, BOp1);
1664 return new ICmpInst(ICI.getPredicate(), BOp0, Neg);
1672 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1676 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1684 return new ICmpInst(ICI.getPredicate(), BO->getOperand(1),
1688 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1698 return ReplaceInstUsesWith(ICI, Builder->getInt1(isICMP_NE));
1707 return ReplaceInstUsesWith(ICI, Builder->getInt1(isICMP_NE));
1745 return new ICmpInst(ICI.getPredicate(), BO->getOperand(0),
1757 ICI.setOperand(0, II->getArgOperand(0));
1758 ICI.setOperand(1, Builder->getInt(RHSV.byteSwap()));
1759 return &ICI;
1765 ICI.setOperand(0, II->getArgOperand(0));
1766 ICI.setOperand(1, ConstantInt::get(RHS->getType(), 0));
1767 return &ICI;
1774 ICI.setOperand(0, II->getArgOperand(0));
1775 ICI.setOperand(1, RHS);
1776 return &ICI;
1790 Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
1791 const CastInst *LHSCI = cast<CastInst>(ICI.getOperand(0));
1802 if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
1804 } else if (PtrToIntInst *RHSC = dyn_cast<PtrToIntInst>(ICI.getOperand(1))) {
1812 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSOp);
1822 bool isSignedCmp = ICI.isSigned();
1824 if (CastInst *CI = dyn_cast<CastInst>(ICI.getOperand(1))) {
1836 if (ICI.isEquality())
1837 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
1842 return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
1845 return new ICmpInst(ICI.getUnsignedPredicate(), LHSCIOp, RHSCIOp);
1849 ConstantInt *CI = dyn_cast<ConstantInt>(ICI.getOperand(1));
1862 if (ICI.isEquality())
1863 return new ICmpInst(ICI.getPredicate(), LHSCIOp, Res1);
1868 return new ICmpInst(ICI.getPredicate(), LHSCIOp, Res1);
1871 return new ICmpInst(ICI.getUnsignedPredicate(), LHSCIOp, Res1);
1888 Value *Result = Builder->CreateICmpSGT(LHSCIOp, NegOne, ICI.getName());
1891 if (ICI.getPredicate() == ICmpInst::ICMP_ULT)
1892 return ReplaceInstUsesWith(ICI, Result);
1894 assert(ICI.getPredicate() == ICmpInst::ICMP_UGT && "ICmp should be folded!");