Lines Matching defs:Op1

1297   Value *Op0 = Cmp.getOperand(0), *Op1 = Cmp.getOperand(1);
1300 if (Pred == ICmpInst::ICMP_UGT && match(Op1, m_ConstantInt(CI)) &&
1306 Constant *C = dyn_cast<Constant>(Op1);
2970 Value *Op1, IRBuilderBase &Builder,
2984 return HasOneUse ? Builder.CreateNot(Builder.CreateOr(Op0, Op1)) : nullptr;
2986 return HasOneUse ? Builder.CreateAnd(Builder.CreateNot(Op0), Op1) : nullptr;
2990 return HasOneUse ? Builder.CreateAnd(Op0, Builder.CreateNot(Op1)) : nullptr;
2992 return Builder.CreateNot(Op1);
2994 return Builder.CreateXor(Op0, Op1);
2996 return HasOneUse ? Builder.CreateNot(Builder.CreateAnd(Op0, Op1)) : nullptr;
2998 return Builder.CreateAnd(Op0, Op1);
3000 return HasOneUse ? Builder.CreateNot(Builder.CreateXor(Op0, Op1)) : nullptr;
3002 return Op1;
3004 return HasOneUse ? Builder.CreateOr(Builder.CreateNot(Op0), Op1) : nullptr;
3008 return HasOneUse ? Builder.CreateOr(Op0, Builder.CreateNot(Op1)) : nullptr;
3010 return Builder.CreateOr(Op0, Op1);
3026 Value *Op0, *Op1;
3032 m_ZExtOrSExt(m_Value(Op1))))) &&
3034 Op1->getType()->isIntOrIntVectorTy(1)) {
3051 createLogicFromTable(Table, Op0, Op1, Builder, Add->hasOneUse()))
3266 Value *Op1 = Cmp.getOperand(1);
3284 match(Op1, m_Zero()))
3288 if (Pred == ICmpInst::ICMP_SLT && match(Op1, m_One()))
3292 if (Pred == ICmpInst::ICMP_SGT && match(Op1, m_AllOnes()))
3301 if (Cmp.isEquality() && match(Op1, m_Zero()))
3306 if (match(Op1, m_APInt(C)) && Bitcast->hasOneUse()) {
3722 Value *Op1 = Cmp.getOperand(1);
3724 const auto *IIOp1 = dyn_cast<IntrinsicInst>(Op1);
3874 Value *Op1 = II->getOperand(1);
3879 if (!match(Op1, m_APInt(COp1)))
3932 Builder.CreateAdd(Op0, ConstantInt::get(Op1->getType(), EquivOffset)),
3933 ConstantInt::get(Op1->getType(), EquivInt));
4092 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
4093 Constant *RHSC = dyn_cast<Constant>(Op1);
4141 Value *Op1 = SimplifyOp(SI->getOperand(1), true);
4142 if (Op1)
4143 CI = dyn_cast<ConstantInt>(Op1);
4157 if (Op1 && Op2)
4159 else if (Op1 || Op2) {
4165 // When Op1 is constant try replacing select with second operand.
4168 Transform = replacedSelectWithOperand(SI, &I, Op1 ? 2 : 1);
4171 if (!Op1)
4172 Op1 = Builder.CreateICmp(Pred, SI->getOperand(1), RHS, I.getName());
4175 return SelectInst::Create(SI->getOperand(0), Op1, Op2);
4290 Value *Op1, const SimplifyQuery &Q,
4350 if (match(Op0, m_c_And(m_Specific(Op1), m_Value(M)))) {
4351 X = Op1;
4364 if (ICmpInst::isEquality(Pred) && match(Op1, m_AllOnes()) &&
4383 if (ICmpInst::isEquality(Pred) && match(Op1, m_Zero()) &&
4771 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1), *A;
4774 if (match(Op1, m_c_And(m_Specific(Op0), m_Value()))) {
4775 std::swap(Op0, Op1);
4779 if (!match(Op0, m_c_And(m_Specific(Op1), m_Value(A))))
4784 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
4788 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
4794 if (!match(Op1, m_ImmConstant()))
4796 IC.getFreelyInverted(Op1, !Op1->hasNUsesOrMore(3), &IC.Builder))
4798 Constant::getAllOnesValue(Op1->getType()));
4801 return new ICmpInst(Pred, IC.Builder.CreateAnd(Op1, NotA),
4802 Constant::getNullValue(Op1->getType()));
4811 return new ICmpInst(ICmpInst::getUnsignedPredicate(Pred), Op0, Op1);
4819 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1,
4820 Constant::getNullValue(Op1->getType()));
4822 if (isKnownNegative(Op1, IC.getSimplifyQuery().getWithInstruction(&I)))
4833 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1), *A;
4837 if (match(Op1, m_c_Or(m_Specific(Op0), m_Value(A)))) {
4838 std::swap(Op0, Op1);
4840 } else if (!match(Op0, m_c_Or(m_Specific(Op1), m_Value(A)))) {
4846 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
4850 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
4855 IC.getFreelyInverted(Op1, !Op1->hasNUsesOrMore(3), &IC.Builder))
4857 Constant::getNullValue(Op1->getType()));
4860 return new ICmpInst(Pred, IC.Builder.CreateOr(Op1, NotA),
4861 Constant::getAllOnesValue(Op1->getType()));
4868 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1), *A;
4871 if (match(Op1, m_c_Xor(m_Specific(Op0), m_Value()))) {
4872 std::swap(Op0, Op1);
4875 if (!match(Op0, m_c_Xor(m_Specific(Op1), m_Value(A))))
4884 return new ICmpInst(PredOut, Op0, Op1);
4896 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
4900 BinaryOperator *BO1 = dyn_cast<BinaryOperator>(Op1);
4911 // (Op1 + X) u</u>= Op1 --> ~Op1 u</u>= X
4912 if (match(Op0, m_OneUse(m_c_Add(m_Specific(Op1), m_Value(X)))) &&
4914 return new ICmpInst(Pred, Builder.CreateNot(Op1), X);
4916 if (match(Op1, m_OneUse(m_c_Add(m_Specific(Op0), m_Value(X)))) &&
4921 // (Op1 + X) + C u</u>= Op1 --> ~C - X u</u>= Op1
4923 if (match(Op0, m_OneUse(m_Add(m_c_Add(m_Specific(Op1), m_Value(X)),
4927 return new ICmpInst(Pred, Builder.CreateSub(C2, X), Op1);
4930 if (match(Op1, m_OneUse(m_Add(m_c_Add(m_Specific(Op0), m_Value(X)),
4940 // ((Op1 + C) & C) u< Op1 --> Op1 != 0
4941 // ((Op1 + C) & C) u>= Op1 --> Op1 == 0
4948 match(BO, m_Add(m_Specific(Op1), m_SpecificIntAllowPoison(*C)))) {
4951 Constant *Zero = ConstantInt::getNullValue(Op1->getType());
4952 return new ICmpInst(NewPred, Op1, Zero);
4956 match(Op1, m_And(m_BinOp(BO), m_LowBitMask(C))) &&
4960 Constant *Zero = ConstantInt::getNullValue(Op1->getType());
4968 // Analyze the case when either Op0 or Op1 is an add instruction.
4969 // Op0 = A + B (or A and B are null); Op1 = C + D (or C and D are null).
4999 if ((A == Op1 || B == Op1) && NoOp0WrapProblem)
5000 return new ICmpInst(Pred, A == Op1 ? B : A,
5001 Constant::getNullValue(Op1->getType()));
5035 // icmp slt (A + -1), Op1 -> icmp sle A, Op1
5038 return new ICmpInst(CmpInst::ICMP_SLE, A, Op1);
5040 // icmp sge (A + -1), Op1 -> icmp sgt A, Op1
5043 return new ICmpInst(CmpInst::ICMP_SGT, A, Op1);
5045 // icmp sle (A + 1), Op1 -> icmp slt A, Op1
5047 return new ICmpInst(CmpInst::ICMP_SLT, A, Op1);
5049 // icmp sgt (A + 1), Op1 -> icmp sge A, Op1
5051 return new ICmpInst(CmpInst::ICMP_SGE, A, Op1);
5075 // icmp ult (A - 1), Op1 -> icmp ule A, Op1
5076 // icmp uge (A - 1), Op1 -> icmp ugt A, Op1
5080 // icmp ule (A + 1), Op0 -> icmp ult A, Op1
5082 return new ICmpInst(CmpInst::ICMP_ULT, A, Op1);
5084 // icmp ugt (A + 1), Op0 -> icmp uge A, Op1
5086 return new ICmpInst(CmpInst::ICMP_UGE, A, Op1);
5136 // Analyze the case when either Op0 or Op1 is a sub instruction.
5137 // Op0 = A - B (or A and B are null); Op1 = C - D (or C and D are null).
5152 if (A == Op1 && NoOp0WrapProblem)
5153 return new ICmpInst(Pred, Constant::getNullValue(Op1->getType()), B);
5160 if (A == Op1 && (Pred == ICmpInst::ICMP_UGT || Pred == ICmpInst::ICMP_ULE))
5166 if (A == Op1 && (Pred == ICmpInst::ICMP_UGE || Pred == ICmpInst::ICMP_ULT) &&
5186 if (Constant *RHSC = dyn_cast<Constant>(Op1))
5203 match(Op1, m_c_Mul(m_Specific(Z), m_Value(Y)))) ||
5205 match(Op1, m_c_Mul(m_Specific(Z), m_Value(Y)))))) {
5230 if (BO0 && BO0->getOpcode() == Instruction::SRem && Op1 == BO0->getOperand(1))
5337 auto LSubOne = m_Add(m_Specific(Op1), m_AllOnes());
5342 return new ICmpInst(ICmpInst::ICMP_NE, Op1, Zero);
5350 if (match(Op0, m_Shl(m_Specific(Op1), m_One())))
5351 return new ICmpInst(ICmpInst::getSignedPredicate(Pred), Op1,
5352 Constant::getNullValue(Op1->getType()));
5353 else if (match(Op1, m_Shl(m_Specific(Op0), m_One())))
5518 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
5527 !match(Op1, m_ZeroInt()))
5532 if (match(Op0, m_OneUse(m_c_And(m_Neg(m_Specific(Op1)), m_Specific(Op1)))))
5533 A = Op1;
5534 else if (match(Op1,
5544 match(Op0, m_OneUse(m_c_Xor(m_Add(m_Specific(Op1), m_AllOnes()),
5545 m_Specific(Op1))))) {
5546 A = Op1;
5549 match(Op1, m_OneUse(m_c_Xor(m_Add(m_Specific(Op0), m_AllOnes()),
5572 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
5576 if (A == Op1 || B == Op1) { // (A^B) == A -> B == 0
5577 Value *OtherVal = A == Op1 ? B : A;
5581 if (match(Op1, m_Xor(m_Value(C), m_Value(D)))) {
5585 Op1->hasOneUse()) {
5603 if (match(Op1, m_Xor(m_Value(A), m_Value(B))) && (A == Op0 || B == Op0)) {
5611 match(Op1, m_And(m_Value(C), m_Value(D)))) {
5640 // If either Op0/Op1 are both one use or X^Y will constant fold and one of
5641 // Op0/Op1 are one use, proceed. In those cases we are instruction neutral
5644 int(Op0->hasOneUse()) + int(Op1->hasOneUse()) +
5648 Op1 = Builder.CreateXor(X, Y);
5649 Op1 = Builder.CreateAnd(Op1, Z);
5650 return new ICmpInst(Pred, Op1, Constant::getNullValue(Op1->getType()));
5661 match(Op1, m_OneUse(m_Or(m_Value(Y), m_Specific(C))))) {
5668 if (match(Op1, m_ZExt(m_Value(A))) &&
5669 (Op0->hasOneUse() || Op1->hasOneUse())) {
5682 match(Op1, m_OneUse(m_LShr(m_Value(B), m_APIntAllowPoison(AP2))))) ||
5684 match(Op1, m_OneUse(m_AShr(m_Value(B), m_APIntAllowPoison(AP2)))))) {
5701 match(Op1, m_OneUse(m_Shl(m_Value(B), m_Specific(Cst1))))) {
5718 match(Op1, m_ConstantInt(Cst1)) &&
5746 match(Op1, m_Trunc(m_LShr(m_Specific(A), m_SpecificInt(BitWidth)))) &&
5760 if (match(Op0, m_c_And(m_Specific(Op1), m_Value())) &&
5761 isKnownToBeAPowerOfTwo(Op1, /* OrZero */ false, 0, &I))
5765 if (match(Op1, m_c_And(m_Specific(Op0), m_Value())) &&
5767 return new ICmpInst(CmpInst::getInversePredicate(Pred), Op1,
5768 ConstantInt::getNullValue(Op1->getType()));
5822 Value *Op0 = ICmp.getOperand(0), *Op1 = ICmp.getOperand(1);
5828 if (!match(Op0, m_OneUse(m_Trunc(m_Value(X)))) || !match(Op1, m_APInt(C)))
5835 if (decomposeBitTestICmp(Op0, Op1, Pred, X, Mask, true /* WithTrunc */)) {
6435 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
6485 return new ICmpInst(Pred, ConstantExpr::getIntegerValue(Ty, Op0Min), Op1);
6486 if (!isa<Constant>(Op1) && Op1Min == Op1Max)
6501 match(Op1, m_MaxOrMin(m_Value(), m_Value()));
6509 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
6511 if (match(Op1, m_APInt(CmpC))) {
6515 ConstantInt::get(Op1->getType(), *CmpC - 1));
6520 Constant::getNullValue(Op1->getType()));
6526 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
6528 if (match(Op1, m_APInt(CmpC))) {
6532 ConstantInt::get(Op1->getType(), *CmpC + 1));
6537 Constant::getNullValue(Op1->getType()));
6543 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
6545 if (match(Op1, m_APInt(CmpC))) {
6548 ConstantInt::get(Op1->getType(), *CmpC - 1));
6554 return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
6556 if (match(Op1, m_APInt(CmpC))) {
6559 ConstantInt::get(Op1->getType(), *CmpC + 1));
6613 ConstantInt::getNullValue(Op1->getType()));
6645 assert(!isa<ConstantInt>(Op1) && "ICMP_SGE with ConstantInt not folded!");
6651 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
6654 assert(!isa<ConstantInt>(Op1) && "ICMP_SLE with ConstantInt not folded!");
6660 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
6663 assert(!isa<ConstantInt>(Op1) && "ICMP_UGE with ConstantInt not folded!");
6669 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
6672 assert(!isa<ConstantInt>(Op1) && "ICMP_ULE with ConstantInt not folded!");
6678 return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
6687 return new ICmpInst(I.getUnsignedPredicate(), Op0, Op1);
6863 Value *Op1 = I.getOperand(1);
6864 auto *Op1C = dyn_cast<Constant>(Op1);
7094 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
7101 ((Pred == ICmpInst::ICMP_ULT && (Op1 == A || Op1 == B)) ||
7102 (Pred == ICmpInst::ICMP_EQ && match(Op1, m_ZeroInt()) &&
7104 (Pred == ICmpInst::ICMP_NE && match(Op1, m_AllOnes()) &&
7110 else if (match(Op1, UAddOvResultPat) &&
7113 UAddOv = cast<ExtractValueInst>(Op1)->getAggregateOperand();
7188 Value *Op0, Value *Op1,
7192 if (Instruction *NI = foldGEPICmp(GEP, Op1, Pred, CxtI))
7196 if (Instruction *NI = foldSelectICmp(Pred, SI, Op1, CxtI))
7200 if (Instruction *Res = foldICmpWithMinMax(CxtI, MinMax, Op1, Pred))
7207 if (match(Op0, m_Add(m_Value(X), m_APInt(C))) && Op1 == X)
7225 match(Op1, m_Specific(X))) {
7263 if (Value *V = foldICmpWithLowBitMaskedVal(Pred, Op0, Op1, Q, *this))
7269 if (match(Op0, m_UDiv(m_Specific(Op1), m_CheckedInt(CheckUGT1)))) {
7270 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1,
7271 Constant::getNullValue(Op1->getType()));
7275 match(Op0, m_SDiv(m_Specific(Op1), m_CheckedInt(CheckUGT1)))) {
7276 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1,
7277 Constant::getNullValue(Op1->getType()));
7284 if (match(Op0, m_LShr(m_Specific(Op1), m_CheckedInt(CheckNE0)))) {
7285 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1,
7286 Constant::getNullValue(Op1->getType()));
7290 match(Op0, m_AShr(m_Specific(Op1), m_CheckedInt(CheckNE0)))) {
7291 return new ICmpInst(ICmpInst::getSwappedPredicate(Pred), Op1,
7292 Constant::getNullValue(Op1->getType()));
7302 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
7304 unsigned Op1Cplxity = getComplexity(Op1);
7311 std::swap(Op0, Op1);
7315 if (Value *V = simplifyICmpInst(I.getPredicate(), Op0, Op1, Q))
7320 if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) {
7326 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
7330 return CmpInst::Create(Instruction::ICmp, I.getPredicate(), V, Op1);
7388 if (match(Op1, m_APInt(C))) {
7422 if (Instruction *Res = foldICmpCommutative(I.getPredicate(), Op0, Op1, I))
7425 foldICmpCommutative(I.getSwappedPredicate(), Op1, Op0, I))
7452 match(Op1, m_Select(m_Specific(Cond), m_Value(C), m_Value(D))) &&
7453 (Op0->hasOneUse() || Op1->hasOneUse())) {
7469 assert(Op1->getType()->isPointerTy() && "Comparing pointer with non-pointer?");
7473 if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(Op1)))
7491 match(Op1, m_Zero()) && isKnownToBeAPowerOfTwo(X, false, 0, &I) &&
7494 Op1);
7496 // Op0 pred Op1 -> ~Op1 pred ~Op0, if this allows us to drop an instruction.
7500 isFreeToInvert(Op1, Op1->hasOneUse(), ConsumesOp1) &&
7503 Value *InvOp1 = getFreelyInverted(Op1, Op1->hasOneUse(), &Builder);
7529 match(Op1, m_APInt(C))) {
7539 match(Op1,
7542 (Op0->hasOneUse() || Op1->hasOneUse())) {
7582 if (EVI->getIndices()[0] == 0 && ACXI->getCompareOperand() == Op1 &&
7988 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
7990 // Canonicalize fneg as Op1.
7991 if (match(Op0, m_FNeg(m_Value())) && !match(Op1, m_FNeg(m_Value()))) {
7992 std::swap(Op0, Op1);
7996 if (!match(Op1, m_FNeg(m_Specific(Op0))))
8064 Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
8065 if (Value *V = simplifyFCmpInst(Pred, Op0, Op1, I.getFastMathFlags(),
8071 assert(OpType == Op1->getType() && "fcmp with different-typed operands?");
8072 if (Op0 == Op1) {
8110 if (!match(Op1, m_PosZeroFP()) &&
8111 isKnownNeverNaN(Op1, 0, getSimplifyQuery().getWithInstruction(&I)))
8117 if (match(Op0, m_FNeg(m_Value(X))) && match(Op1, m_FNeg(m_Value(Y))))
8140 if (match(Op1, m_AnyZeroFP()) && !match(Op1, m_PosZeroFP()))
8161 if (match(Op1, m_APFloat(C)) && C->isInfinity()) {
8173 return new FCmpInst(FCmpInst::FCMP_ONE, Op0, Op1, "", &I);
8178 return new FCmpInst(FCmpInst::FCMP_OEQ, Op0, Op1, "", &I);
8180 return new FCmpInst(FCmpInst::FCMP_UNE, Op0, Op1, "", &I);
8185 return new FCmpInst(FCmpInst::FCMP_UEQ, Op0, Op1, "", &I);
8191 if (match(Op1, m_PosZeroFP()) &&
8210 if (match(Op0, m_Instruction(LHSI)) && match(Op1, m_Constant(RHSC))) {
8256 if (match(Op1, m_Constant(C)))
8263 return new FCmpInst(Pred, X, Op1, "", &I);
8266 if (match(Op1, m_FAdd(m_Value(Y), m_AnyZeroFP())))
8271 if (match(Op1, m_FPExt(m_Value(Y))) && X->getType() == Y->getType())
8275 if (match(Op1, m_APFloat(C))) {
8325 match(Op1, m_AnyZeroFP()) && !C->isZero() && !C->isNaN()) {
8341 match(Op1, m_Intrinsic<Intrinsic::canonicalize>(m_Value(CanonRHS)));
8344 if (CanonLHS == Op1)
8345 return new FCmpInst(Pred, Op1, Op1, "", &I);