Lines Matching refs:Op1
301 BinaryOperator *Op1 = dyn_cast<BinaryOperator>(RHS); in simplifyAssociativeBinOp() local
324 if (Op1 && Op1->getOpcode() == Opcode) { in simplifyAssociativeBinOp()
326 Value *B = Op1->getOperand(0); in simplifyAssociativeBinOp()
327 Value *C = Op1->getOperand(1); in simplifyAssociativeBinOp()
368 if (Op1 && Op1->getOpcode() == Opcode) { in simplifyAssociativeBinOp()
370 Value *B = Op1->getOperand(0); in simplifyAssociativeBinOp()
371 Value *C = Op1->getOperand(1); in simplifyAssociativeBinOp()
608 Value *&Op0, Value *&Op1, in foldOrCommuteConstant() argument
611 if (auto *CRHS = dyn_cast<Constant>(Op1)) { in foldOrCommuteConstant()
628 std::swap(Op0, Op1); in foldOrCommuteConstant()
635 static Value *simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyAddInst() argument
637 if (Constant *C = foldOrCommuteConstant(Instruction::Add, Op0, Op1, Q)) in simplifyAddInst()
641 if (isa<PoisonValue>(Op1)) in simplifyAddInst()
642 return Op1; in simplifyAddInst()
645 if (Q.isUndefValue(Op1)) in simplifyAddInst()
646 return Op1; in simplifyAddInst()
649 if (match(Op1, m_Zero())) in simplifyAddInst()
653 if (isKnownNegation(Op0, Op1)) in simplifyAddInst()
660 if (match(Op1, m_Sub(m_Value(Y), m_Specific(Op0))) || in simplifyAddInst()
661 match(Op0, m_Sub(m_Value(Y), m_Specific(Op1)))) in simplifyAddInst()
666 if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) in simplifyAddInst()
672 if ((IsNSW || IsNUW) && match(Op1, m_SignMask()) && in simplifyAddInst()
677 if (IsNUW && match(Op1, m_AllOnes())) in simplifyAddInst()
678 return Op1; // Which is -1. in simplifyAddInst()
682 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1)) in simplifyAddInst()
687 simplifyAssociativeBinOp(Instruction::Add, Op0, Op1, Q, MaxRecurse)) in simplifyAddInst()
702 Value *llvm::simplifyAddInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyAddInst() argument
704 return ::simplifyAddInst(Op0, Op1, IsNSW, IsNUW, Query, RecursionLimit); in simplifyAddInst()
753 static Value *simplifyByDomEq(unsigned Opcode, Value *Op0, Value *Op1, in simplifyByDomEq() argument
760 isImpliedByDomCondition(CmpInst::ICMP_EQ, Op0, Op1, Q.CxtI, Q.DL); in simplifyByDomEq()
777 return Op1; in simplifyByDomEq()
787 static Value *simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifySubInst() argument
789 if (Constant *C = foldOrCommuteConstant(Instruction::Sub, Op0, Op1, Q)) in simplifySubInst()
794 if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1)) in simplifySubInst()
799 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) in simplifySubInst()
803 if (match(Op1, m_Zero())) in simplifySubInst()
807 if (Op0 == Op1) in simplifySubInst()
816 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q); in simplifySubInst()
824 return Op1; in simplifySubInst()
830 Value *X = nullptr, *Y = nullptr, *Z = Op1; in simplifySubInst()
853 if (MaxRecurse && match(Op1, m_Add(m_Value(Y), m_Value(Z)))) { // X - (Y + Z) in simplifySubInst()
875 if (MaxRecurse && match(Op1, m_Sub(m_Value(X), m_Value(Y)))) // Z - (X - Y) in simplifySubInst()
887 match(Op1, m_Trunc(m_Value(Y)))) in simplifySubInst()
898 if (match(Op0, m_PtrToInt(m_Value(X))) && match(Op1, m_PtrToInt(m_Value(Y)))) in simplifySubInst()
905 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1)) in simplifySubInst()
917 if (Value *V = simplifyByDomEq(Instruction::Sub, Op0, Op1, Q, MaxRecurse)) in simplifySubInst()
923 Value *llvm::simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifySubInst() argument
925 return ::simplifySubInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit); in simplifySubInst()
930 static Value *simplifyMulInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyMulInst() argument
932 if (Constant *C = foldOrCommuteConstant(Instruction::Mul, Op0, Op1, Q)) in simplifyMulInst()
936 if (isa<PoisonValue>(Op1)) in simplifyMulInst()
937 return Op1; in simplifyMulInst()
941 if (Q.isUndefValue(Op1) || match(Op1, m_Zero())) in simplifyMulInst()
945 if (match(Op1, m_One())) in simplifyMulInst()
952 m_Exact(m_IDiv(m_Value(X), m_Specific(Op1)))) || // (X / Y) * Y in simplifyMulInst()
953 match(Op1, m_Exact(m_IDiv(m_Value(X), m_Specific(Op0)))))) // Y * (X / Y) in simplifyMulInst()
964 if (Value *V = simplifyAndInst(Op0, Op1, Q, MaxRecurse - 1)) in simplifyMulInst()
970 simplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) in simplifyMulInst()
974 if (Value *V = expandCommutativeBinOp(Instruction::Mul, Op0, Op1, in simplifyMulInst()
980 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) in simplifyMulInst()
982 threadBinOpOverSelect(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) in simplifyMulInst()
987 if (isa<PHINode>(Op0) || isa<PHINode>(Op1)) in simplifyMulInst()
989 threadBinOpOverPHI(Instruction::Mul, Op0, Op1, Q, MaxRecurse)) in simplifyMulInst()
995 Value *llvm::simplifyMulInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyMulInst() argument
997 return ::simplifyMulInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit); in simplifyMulInst()
1079 Value *Op1, const SimplifyQuery &Q, in simplifyDivRem() argument
1088 if (Q.isUndefValue(Op1) || isa<PoisonValue>(Op1)) in simplifyDivRem()
1094 if (match(Op1, m_Zero())) in simplifyDivRem()
1099 auto *Op1C = dyn_cast<Constant>(Op1); in simplifyDivRem()
1127 if (Op0 == Op1) in simplifyDivRem()
1130 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q); in simplifyDivRem()
1151 if (match(Op0, m_c_Mul(m_Value(X), m_Specific(Op1)))) { in simplifyDivRem()
1157 (IsSigned && match(X, m_SDiv(m_Value(), m_Specific(Op1)))) || in simplifyDivRem()
1158 (!IsSigned && match(X, m_UDiv(m_Value(), m_Specific(Op1))))) { in simplifyDivRem()
1163 if (isDivZero(Op0, Op1, Q, MaxRecurse, IsSigned)) in simplifyDivRem()
1166 if (Value *V = simplifyByDomEq(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyDivRem()
1171 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) in simplifyDivRem()
1172 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyDivRem()
1177 if (isa<PHINode>(Op0) || isa<PHINode>(Op1)) in simplifyDivRem()
1178 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyDivRem()
1185 static Value *simplifyDiv(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, in simplifyDiv() argument
1188 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q)) in simplifyDiv()
1191 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyDiv()
1195 if (IsExact && match(Op1, m_APInt(DivC))) { in simplifyDiv()
1211 ? match(Op0, m_NSWMul(m_Value(X), m_Specific(Op1))) in simplifyDiv()
1212 : match(Op0, m_NUWMul(m_Value(X), m_Specific(Op1))))) in simplifyDiv()
1220 static Value *simplifyRem(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1, in simplifyRem() argument
1222 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q)) in simplifyRem()
1225 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyRem()
1231 match(Op0, m_NSWShl(m_Specific(Op1), m_Value()))) || in simplifyRem()
1233 match(Op0, m_NUWShl(m_Specific(Op1), m_Value())))) in simplifyRem()
1237 if (match(Op1, m_APInt(C0))) { in simplifyRem()
1257 static Value *simplifySDivInst(Value *Op0, Value *Op1, bool IsExact, in simplifySDivInst() argument
1260 if (isKnownNegation(Op0, Op1, /*NeedNSW=*/true)) in simplifySDivInst()
1263 return simplifyDiv(Instruction::SDiv, Op0, Op1, IsExact, Q, MaxRecurse); in simplifySDivInst()
1266 Value *llvm::simplifySDivInst(Value *Op0, Value *Op1, bool IsExact, in simplifySDivInst() argument
1268 return ::simplifySDivInst(Op0, Op1, IsExact, Q, RecursionLimit); in simplifySDivInst()
1273 static Value *simplifyUDivInst(Value *Op0, Value *Op1, bool IsExact, in simplifyUDivInst() argument
1275 return simplifyDiv(Instruction::UDiv, Op0, Op1, IsExact, Q, MaxRecurse); in simplifyUDivInst()
1278 Value *llvm::simplifyUDivInst(Value *Op0, Value *Op1, bool IsExact, in simplifyUDivInst() argument
1280 return ::simplifyUDivInst(Op0, Op1, IsExact, Q, RecursionLimit); in simplifyUDivInst()
1285 static Value *simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifySRemInst() argument
1290 if (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1)) in simplifySRemInst()
1294 if (isKnownNegation(Op0, Op1)) in simplifySRemInst()
1297 return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse); in simplifySRemInst()
1300 Value *llvm::simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { in simplifySRemInst() argument
1301 return ::simplifySRemInst(Op0, Op1, Q, RecursionLimit); in simplifySRemInst()
1306 static Value *simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifyURemInst() argument
1308 return simplifyRem(Instruction::URem, Op0, Op1, Q, MaxRecurse); in simplifyURemInst()
1311 Value *llvm::simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { in simplifyURemInst() argument
1312 return ::simplifyURemInst(Op0, Op1, Q, RecursionLimit); in simplifyURemInst()
1348 Value *Op1, bool IsNSW, const SimplifyQuery &Q, in simplifyShift() argument
1350 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q)) in simplifyShift()
1365 if (match(Op1, m_Zero()) || in simplifyShift()
1366 (match(Op1, m_SExt(m_Value(X))) && X->getType()->isIntOrIntVectorTy(1))) in simplifyShift()
1370 if (isPoisonShift(Op1, Q)) in simplifyShift()
1375 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) in simplifyShift()
1376 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyShift()
1381 if (isa<PHINode>(Op0) || isa<PHINode>(Op1)) in simplifyShift()
1382 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse)) in simplifyShift()
1387 KnownBits KnownAmt = computeKnownBits(Op1, /* Depth */ 0, Q); in simplifyShift()
1418 Value *Op1, bool IsExact, in simplifyRightShift() argument
1421 simplifyShift(Opcode, Op0, Op1, /*IsNSW*/ false, Q, MaxRecurse)) in simplifyRightShift()
1425 if (Op0 == Op1) in simplifyRightShift()
1446 static Value *simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyShlInst() argument
1449 simplifyShift(Instruction::Shl, Op0, Op1, IsNSW, Q, MaxRecurse)) in simplifyShlInst()
1461 match(Op0, m_Exact(m_Shr(m_Value(X), m_Specific(Op1))))) in simplifyShlInst()
1474 match(Op1, m_SpecificInt(Ty->getScalarSizeInBits() - 1))) in simplifyShlInst()
1480 Value *llvm::simplifyShlInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW, in simplifyShlInst() argument
1482 return ::simplifyShlInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit); in simplifyShlInst()
1487 static Value *simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact, in simplifyLShrInst() argument
1489 if (Value *V = simplifyRightShift(Instruction::LShr, Op0, Op1, IsExact, Q, in simplifyLShrInst()
1495 if (Q.IIQ.UseInstrInfo && match(Op0, m_NUWShl(m_Value(X), m_Specific(Op1)))) in simplifyLShrInst()
1505 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(ShRAmt)) && in simplifyLShrInst()
1517 Value *llvm::simplifyLShrInst(Value *Op0, Value *Op1, bool IsExact, in simplifyLShrInst() argument
1519 return ::simplifyLShrInst(Op0, Op1, IsExact, Q, RecursionLimit); in simplifyLShrInst()
1524 static Value *simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact, in simplifyAShrInst() argument
1526 if (Value *V = simplifyRightShift(Instruction::AShr, Op0, Op1, IsExact, Q, in simplifyAShrInst()
1534 match(Op0, m_Shl(m_AllOnes(), m_Specific(Op1)))) in simplifyAShrInst()
1539 if (Q.IIQ.UseInstrInfo && match(Op0, m_NSWShl(m_Value(X), m_Specific(Op1)))) in simplifyAShrInst()
1550 Value *llvm::simplifyAShrInst(Value *Op0, Value *Op1, bool IsExact, in simplifyAShrInst() argument
1552 return ::simplifyAShrInst(Op0, Op1, IsExact, Q, RecursionLimit); in simplifyAShrInst()
1703 static Value *simplifyAndOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1, in simplifyAndOfICmpsWithAdd() argument
1712 if (!match(Op1, m_ICmp(Pred1, m_Specific(V), m_Value()))) in simplifyAndOfICmpsWithAdd()
1716 if (AddInst->getOperand(1) != Op1->getOperand(1)) in simplifyAndOfICmpsWithAdd()
1771 static Value *simplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1, in simplifyAndOfICmps() argument
1773 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/true, Q)) in simplifyAndOfICmps()
1775 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/true, Q)) in simplifyAndOfICmps()
1778 if (Value *X = simplifyAndOrOfICmpsWithConstants(Op0, Op1, true)) in simplifyAndOfICmps()
1781 if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op0, Op1, true)) in simplifyAndOfICmps()
1783 if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op1, Op0, true)) in simplifyAndOfICmps()
1786 if (Value *X = simplifyAndOfICmpsWithAdd(Op0, Op1, Q.IIQ)) in simplifyAndOfICmps()
1788 if (Value *X = simplifyAndOfICmpsWithAdd(Op1, Op0, Q.IIQ)) in simplifyAndOfICmps()
1794 static Value *simplifyOrOfICmpsWithAdd(ICmpInst *Op0, ICmpInst *Op1, in simplifyOrOfICmpsWithAdd() argument
1803 if (!match(Op1, m_ICmp(Pred1, m_Specific(V), m_Value()))) in simplifyOrOfICmpsWithAdd()
1807 if (AddInst->getOperand(1) != Op1->getOperand(1)) in simplifyOrOfICmpsWithAdd()
1841 static Value *simplifyOrOfICmps(ICmpInst *Op0, ICmpInst *Op1, in simplifyOrOfICmps() argument
1843 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/false, Q)) in simplifyOrOfICmps()
1845 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/false, Q)) in simplifyOrOfICmps()
1848 if (Value *X = simplifyAndOrOfICmpsWithConstants(Op0, Op1, false)) in simplifyOrOfICmps()
1851 if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op0, Op1, false)) in simplifyOrOfICmps()
1853 if (Value *X = simplifyAndOrOfICmpsWithCtpop(Op1, Op0, false)) in simplifyOrOfICmps()
1856 if (Value *X = simplifyOrOfICmpsWithAdd(Op0, Op1, Q.IIQ)) in simplifyOrOfICmps()
1858 if (Value *X = simplifyOrOfICmpsWithAdd(Op1, Op0, Q.IIQ)) in simplifyOrOfICmps()
1902 Value *Op1, bool IsAnd) { in simplifyAndOrOfCmps() argument
1905 auto *Cast1 = dyn_cast<CastInst>(Op1); in simplifyAndOrOfCmps()
1909 Op1 = Cast1->getOperand(0); in simplifyAndOrOfCmps()
1914 auto *ICmp1 = dyn_cast<ICmpInst>(Op1); in simplifyAndOrOfCmps()
1920 auto *FCmp1 = dyn_cast<FCmpInst>(Op1); in simplifyAndOrOfCmps()
1944 static Value *simplifyAndOrWithICmpEq(unsigned Opcode, Value *Op0, Value *Op1, in simplifyAndOrWithICmpEq() argument
1974 return Op1; in simplifyAndOrWithICmpEq()
1981 if (Value *Res = simplifyWithOpReplaced(Op1, A, B, Q.getWithoutUndef(), in simplifyAndOrWithICmpEq()
1985 if (Value *Res = simplifyWithOpReplaced(Op1, B, A, Q.getWithoutUndef(), in simplifyAndOrWithICmpEq()
1995 static Value *simplifyLogicOfAddSub(Value *Op0, Value *Op1, in simplifyLogicOfAddSub() argument
1997 assert(Op0->getType() == Op1->getType() && "Mismatched binop types"); in simplifyLogicOfAddSub()
2002 match(Op1, m_Sub(m_Constant(C2), m_Specific(X)))) || in simplifyLogicOfAddSub()
2003 (match(Op1, m_Add(m_Value(X), m_Constant(C1))) && in simplifyLogicOfAddSub()
2018 static Value *simplifyAndCommutative(Value *Op0, Value *Op1, in simplifyAndCommutative() argument
2022 if (match(Op0, m_Not(m_Specific(Op1)))) in simplifyAndCommutative()
2026 if (match(Op0, m_c_Or(m_Specific(Op1), m_Value()))) in simplifyAndCommutative()
2027 return Op1; in simplifyAndCommutative()
2032 match(Op1, m_c_Or(m_Specific(X), m_Specific(Y)))) in simplifyAndCommutative()
2038 if (isCheckForZeroAndMulWithOverflow(Op0, Op1, true)) in simplifyAndCommutative()
2039 return Op1; in simplifyAndCommutative()
2042 if (match(Op0, m_Neg(m_Specific(Op1))) && in simplifyAndCommutative()
2043 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT)) in simplifyAndCommutative()
2044 return Op1; in simplifyAndCommutative()
2048 if (match(Op0, m_Add(m_Specific(Op1), m_AllOnes())) && in simplifyAndCommutative()
2049 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT)) in simplifyAndCommutative()
2050 return Constant::getNullValue(Op1->getType()); in simplifyAndCommutative()
2056 match(Op1, m_Add(m_Shl(m_Specific(X), m_APInt(Shift2)), m_AllOnes())) && in simplifyAndCommutative()
2063 simplifyAndOrWithICmpEq(Instruction::And, Op0, Op1, Q, MaxRecurse)) in simplifyAndCommutative()
2071 static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifyAndInst() argument
2073 if (Constant *C = foldOrCommuteConstant(Instruction::And, Op0, Op1, Q)) in simplifyAndInst()
2077 if (isa<PoisonValue>(Op1)) in simplifyAndInst()
2078 return Op1; in simplifyAndInst()
2081 if (Q.isUndefValue(Op1)) in simplifyAndInst()
2085 if (Op0 == Op1) in simplifyAndInst()
2089 if (match(Op1, m_Zero())) in simplifyAndInst()
2093 if (match(Op1, m_AllOnes())) in simplifyAndInst()
2096 if (Value *Res = simplifyAndCommutative(Op0, Op1, Q, MaxRecurse)) in simplifyAndInst()
2098 if (Value *Res = simplifyAndCommutative(Op1, Op0, Q, MaxRecurse)) in simplifyAndInst()
2101 if (Value *V = simplifyLogicOfAddSub(Op0, Op1, Instruction::And)) in simplifyAndInst()
2108 if (match(Op1, m_APInt(Mask))) { in simplifyAndInst()
2125 if (match(Op1, m_Power2(PowerC)) && in simplifyAndInst()
2132 return ConstantInt::getNullValue(Op1->getType()); in simplifyAndInst()
2135 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, true)) in simplifyAndInst()
2140 simplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q, MaxRecurse)) in simplifyAndInst()
2144 if (Value *V = expandCommutativeBinOp(Instruction::And, Op0, Op1, in simplifyAndInst()
2149 if (Value *V = expandCommutativeBinOp(Instruction::And, Op0, Op1, in simplifyAndInst()
2153 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) { in simplifyAndInst()
2156 if (match(Op1, m_Select(m_Specific(Op0), m_Value(), m_Zero()))) in simplifyAndInst()
2157 return Op1; in simplifyAndInst()
2158 else if (match(Op0, m_Select(m_Specific(Op1), m_Value(), m_Zero()))) in simplifyAndInst()
2165 threadBinOpOverSelect(Instruction::And, Op0, Op1, Q, MaxRecurse)) in simplifyAndInst()
2171 if (isa<PHINode>(Op0) || isa<PHINode>(Op1)) in simplifyAndInst()
2173 threadBinOpOverPHI(Instruction::And, Op0, Op1, Q, MaxRecurse)) in simplifyAndInst()
2187 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(Mask)) && in simplifyAndInst()
2215 match(Op1, m_c_Xor(m_Specific(Or), m_Specific(Y)))) in simplifyAndInst()
2222 match(Op1, m_Xor(m_Specific(A), m_SpecificInt(~*C1)))) in simplifyAndInst()
2226 if (std::optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL)) { in simplifyAndInst()
2234 if (std::optional<bool> Implied = isImpliedCondition(Op1, Op0, Q.DL)) { in simplifyAndInst()
2237 return Op1; in simplifyAndInst()
2240 return ConstantInt::getFalse(Op1->getType()); in simplifyAndInst()
2244 if (Value *V = simplifyByDomEq(Instruction::And, Op0, Op1, Q, MaxRecurse)) in simplifyAndInst()
2250 Value *llvm::simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { in simplifyAndInst() argument
2251 return ::simplifyAndInst(Op0, Op1, Q, RecursionLimit); in simplifyAndInst()
2346 static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifyOrInst() argument
2348 if (Constant *C = foldOrCommuteConstant(Instruction::Or, Op0, Op1, Q)) in simplifyOrInst()
2352 if (isa<PoisonValue>(Op1)) in simplifyOrInst()
2353 return Op1; in simplifyOrInst()
2358 if (Q.isUndefValue(Op1) || match(Op1, m_AllOnes())) in simplifyOrInst()
2363 if (Op0 == Op1 || match(Op1, m_Zero())) in simplifyOrInst()
2366 if (Value *R = simplifyOrLogic(Op0, Op1)) in simplifyOrInst()
2368 if (Value *R = simplifyOrLogic(Op1, Op0)) in simplifyOrInst()
2371 if (Value *V = simplifyLogicOfAddSub(Op0, Op1, Instruction::Or)) in simplifyOrInst()
2380 match(Op1, m_LShr(m_AllOnes(), m_Value(Y)))) || in simplifyOrInst()
2381 (match(Op1, m_Shl(m_AllOnes(), m_Value(X))) && in simplifyOrInst()
2398 match(Op1, m_Shl(m_Specific(X), m_Specific(Y)))) in simplifyOrInst()
2400 if (match(Op1, in simplifyOrInst()
2403 return Op1; in simplifyOrInst()
2409 match(Op1, m_LShr(m_Specific(X), m_Specific(Y)))) in simplifyOrInst()
2411 if (match(Op1, in simplifyOrInst()
2414 return Op1; in simplifyOrInst()
2417 simplifyAndOrWithICmpEq(Instruction::Or, Op0, Op1, Q, MaxRecurse)) in simplifyOrInst()
2420 simplifyAndOrWithICmpEq(Instruction::Or, Op1, Op0, Q, MaxRecurse)) in simplifyOrInst()
2423 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, false)) in simplifyOrInst()
2429 if (isCheckForZeroAndMulWithOverflow(Op0, Op1, false)) in simplifyOrInst()
2430 return Op1; in simplifyOrInst()
2431 if (isCheckForZeroAndMulWithOverflow(Op1, Op0, false)) in simplifyOrInst()
2436 simplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, MaxRecurse)) in simplifyOrInst()
2440 if (Value *V = expandCommutativeBinOp(Instruction::Or, Op0, Op1, in simplifyOrInst()
2444 if (isa<SelectInst>(Op0) || isa<SelectInst>(Op1)) { in simplifyOrInst()
2447 if (match(Op1, m_Select(m_Specific(Op0), m_One(), m_Value()))) in simplifyOrInst()
2448 return Op1; in simplifyOrInst()
2449 else if (match(Op0, m_Select(m_Specific(Op1), m_One(), m_Value()))) in simplifyOrInst()
2456 threadBinOpOverSelect(Instruction::Or, Op0, Op1, Q, MaxRecurse)) in simplifyOrInst()
2464 match(Op1, m_And(m_Value(B), m_APInt(C2)))) { in simplifyOrInst()
2488 if (isa<PHINode>(Op0) || isa<PHINode>(Op1)) in simplifyOrInst()
2489 if (Value *V = threadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse)) in simplifyOrInst()
2494 match(Op1, m_Xor(m_Specific(A), m_SpecificInt(~*C1)))) in simplifyOrInst()
2499 isImpliedCondition(Op0, Op1, Q.DL, false)) { in simplifyOrInst()
2508 isImpliedCondition(Op1, Op0, Q.DL, false)) { in simplifyOrInst()
2511 return Op1; in simplifyOrInst()
2514 return ConstantInt::getTrue(Op1->getType()); in simplifyOrInst()
2518 if (Value *V = simplifyByDomEq(Instruction::Or, Op0, Op1, Q, MaxRecurse)) in simplifyOrInst()
2524 Value *llvm::simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { in simplifyOrInst() argument
2525 return ::simplifyOrInst(Op0, Op1, Q, RecursionLimit); in simplifyOrInst()
2530 static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifyXorInst() argument
2532 if (Constant *C = foldOrCommuteConstant(Instruction::Xor, Op0, Op1, Q)) in simplifyXorInst()
2536 if (isa<PoisonValue>(Op1)) in simplifyXorInst()
2537 return Op1; in simplifyXorInst()
2540 if (Q.isUndefValue(Op1)) in simplifyXorInst()
2541 return Op1; in simplifyXorInst()
2544 if (match(Op1, m_Zero())) in simplifyXorInst()
2548 if (Op0 == Op1) in simplifyXorInst()
2552 if (match(Op0, m_Not(m_Specific(Op1))) || match(Op1, m_Not(m_Specific(Op0)))) in simplifyXorInst()
2573 if (Value *R = foldAndOrNot(Op0, Op1)) in simplifyXorInst()
2575 if (Value *R = foldAndOrNot(Op1, Op0)) in simplifyXorInst()
2578 if (Value *V = simplifyLogicOfAddSub(Op0, Op1, Instruction::Xor)) in simplifyXorInst()
2583 simplifyAssociativeBinOp(Instruction::Xor, Op0, Op1, Q, MaxRecurse)) in simplifyXorInst()
2595 if (Value *V = simplifyByDomEq(Instruction::Xor, Op0, Op1, Q, MaxRecurse)) in simplifyXorInst()
2601 Value *llvm::simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) { in simplifyXorInst() argument
2602 return ::simplifyXorInst(Op0, Op1, Q, RecursionLimit); in simplifyXorInst()
5371 static Value *foldIdentityShuffles(int DestElt, Value *Op0, Value *Op1, in foldIdentityShuffles() argument
5388 SourceOp = Op1; in foldIdentityShuffles()
5416 static Value *simplifyShuffleVectorInst(Value *Op0, Value *Op1, in simplifyShuffleVectorInst() argument
5448 Op1 = PoisonValue::get(InVecTy); in simplifyShuffleVectorInst()
5452 auto *Op1Const = dyn_cast<Constant>(Op1); in simplifyShuffleVectorInst()
5464 std::swap(Op0, Op1); in simplifyShuffleVectorInst()
5484 assert(isa<UndefValue>(Op1) && "Expected undef operand 1 for splat"); in simplifyShuffleVectorInst()
5498 if (Q.isUndefValue(Op1) && RetTy == InVecTy && in simplifyShuffleVectorInst()
5522 foldIdentityShuffles(i, Op0, Op1, Indices[i], RootVec, MaxRecurse); in simplifyShuffleVectorInst()
5532 Value *llvm::simplifyShuffleVectorInst(Value *Op0, Value *Op1, in simplifyShuffleVectorInst() argument
5535 return ::simplifyShuffleVectorInst(Op0, Op1, Mask, RetTy, Q, RecursionLimit); in simplifyShuffleVectorInst()
5651 simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFAddInst() argument
5656 if (Constant *C = foldOrCommuteConstant(Instruction::FAdd, Op0, Op1, Q)) in simplifyFAddInst()
5659 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding)) in simplifyFAddInst()
5670 if (match(Op1, m_NegZeroFP())) in simplifyFAddInst()
5675 if (match(Op1, m_PosZeroFP()) && in simplifyFAddInst()
5684 if (match(Op1, m_Inf())) in simplifyFAddInst()
5685 return Op1; in simplifyFAddInst()
5694 if (match(Op0, m_FSub(m_AnyZeroFP(), m_Specific(Op1))) || in simplifyFAddInst()
5695 match(Op1, m_FSub(m_AnyZeroFP(), m_Specific(Op0)))) in simplifyFAddInst()
5698 if (match(Op0, m_FNeg(m_Specific(Op1))) || in simplifyFAddInst()
5699 match(Op1, m_FNeg(m_Specific(Op0)))) in simplifyFAddInst()
5707 (match(Op0, m_FSub(m_Value(X), m_Specific(Op1))) || in simplifyFAddInst()
5708 match(Op1, m_FSub(m_Value(X), m_Specific(Op0))))) in simplifyFAddInst()
5717 simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFSubInst() argument
5722 if (Constant *C = foldOrCommuteConstant(Instruction::FSub, Op0, Op1, Q)) in simplifyFSubInst()
5725 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding)) in simplifyFSubInst()
5732 if (match(Op1, m_PosZeroFP())) in simplifyFSubInst()
5737 if (match(Op1, m_NegZeroFP()) && in simplifyFSubInst()
5745 if (match(Op0, m_NegZeroFP()) && match(Op1, m_FNeg(m_Value(X)))) in simplifyFSubInst()
5752 (match(Op1, m_FSub(m_AnyZeroFP(), m_Value(X))) || in simplifyFSubInst()
5753 match(Op1, m_FNeg(m_Value(X))))) in simplifyFSubInst()
5761 if (Op0 == Op1) in simplifyFSubInst()
5769 if (match(Op1, m_Inf())) in simplifyFSubInst()
5770 return foldConstant(Instruction::FNeg, Op1, Q); in simplifyFSubInst()
5776 (match(Op1, m_FSub(m_Specific(Op0), m_Value(X))) || in simplifyFSubInst()
5777 match(Op0, m_c_FAdd(m_Specific(Op1), m_Value(X))))) in simplifyFSubInst()
5783 static Value *simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFMAFMul() argument
5787 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding)) in simplifyFMAFMul()
5795 std::swap(Op0, Op1); in simplifyFMAFMul()
5798 if (match(Op1, m_FPOne())) in simplifyFMAFMul()
5801 if (match(Op1, m_AnyZeroFP())) { in simplifyFMAFMul()
5811 return Op1; in simplifyFMAFMul()
5814 return foldConstant(Instruction::FNeg, Op1, Q); in simplifyFMAFMul()
5823 if (Op0 == Op1 && match(Op0, m_Sqrt(m_Value(X))) && FMF.allowReassoc() && in simplifyFMAFMul()
5832 simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFMulInst() argument
5837 if (Constant *C = foldOrCommuteConstant(Instruction::FMul, Op0, Op1, Q)) in simplifyFMulInst()
5841 return simplifyFMAFMul(Op0, Op1, FMF, Q, MaxRecurse, ExBehavior, Rounding); in simplifyFMulInst()
5844 Value *llvm::simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFAddInst() argument
5848 return ::simplifyFAddInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFAddInst()
5852 Value *llvm::simplifyFSubInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFSubInst() argument
5856 return ::simplifyFSubInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFSubInst()
5860 Value *llvm::simplifyFMulInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFMulInst() argument
5864 return ::simplifyFMulInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFMulInst()
5868 Value *llvm::simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFMAFMul() argument
5872 return ::simplifyFMAFMul(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFMAFMul()
5877 simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFDivInst() argument
5882 if (Constant *C = foldOrCommuteConstant(Instruction::FDiv, Op0, Op1, Q)) in simplifyFDivInst()
5885 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding)) in simplifyFDivInst()
5892 if (match(Op1, m_FPOne())) in simplifyFDivInst()
5904 if (Op0 == Op1) in simplifyFDivInst()
5909 if (FMF.allowReassoc() && match(Op0, m_c_FMul(m_Value(X), m_Specific(Op1)))) in simplifyFDivInst()
5915 if (match(Op0, m_FNegNSZ(m_Specific(Op1))) || in simplifyFDivInst()
5916 match(Op1, m_FNegNSZ(m_Specific(Op0)))) in simplifyFDivInst()
5920 if (FMF.noInfs() && match(Op1, m_AnyZeroFP())) in simplifyFDivInst()
5921 return PoisonValue::get(Op1->getType()); in simplifyFDivInst()
5927 Value *llvm::simplifyFDivInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFDivInst() argument
5931 return ::simplifyFDivInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFDivInst()
5936 simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFRemInst() argument
5941 if (Constant *C = foldOrCommuteConstant(Instruction::FRem, Op0, Op1, Q)) in simplifyFRemInst()
5944 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding)) in simplifyFRemInst()
5965 Value *llvm::simplifyFRemInst(Value *Op0, Value *Op1, FastMathFlags FMF, in simplifyFRemInst() argument
5969 return ::simplifyFRemInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior, in simplifyFRemInst()
6194 static Value *simplifyLdexp(Value *Op0, Value *Op1, const SimplifyQuery &Q, in simplifyLdexp() argument
6198 if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1)) in simplifyLdexp()
6209 if (Q.isUndefValue(Op1)) in simplifyLdexp()
6237 if (match(Op1, PatternMatch::m_ZeroInt())) in simplifyLdexp()
6362 static Value *foldMinMaxSharedOp(Intrinsic::ID IID, Value *Op0, Value *Op1) { in foldMinMaxSharedOp() argument
6372 if (Op1 == X || Op1 == Y || in foldMinMaxSharedOp()
6373 match(Op1, m_c_MaxOrMin(m_Specific(X), m_Specific(Y)))) { in foldMinMaxSharedOp()
6379 return Op1; in foldMinMaxSharedOp()
6388 Value *Op1) { in foldMinimumMaximumSharedOp() argument
6407 if (X0 == Op1 || Y0 == Op1) in foldMinimumMaximumSharedOp()
6410 auto *M1 = dyn_cast<IntrinsicInst>(Op1); in foldMinimumMaximumSharedOp()
6430 Value *Op0, Value *Op1, in simplifyBinaryIntrinsic() argument
6458 if (isa<PoisonValue>(Op0) || isa<PoisonValue>(Op1)) in simplifyBinaryIntrinsic()
6466 assert(Op1->getType()->getScalarSizeInBits() == in simplifyBinaryIntrinsic()
6471 if (match(Op1, m_PtrToInt(m_Specific(Op0)))) in simplifyBinaryIntrinsic()
6477 if (match(Op1, m_AllOnes()) || Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6481 if (match(Op1, m_ImmConstant(C))) { in simplifyBinaryIntrinsic()
6500 if (Op0 == Op1) in simplifyBinaryIntrinsic()
6505 std::swap(Op0, Op1); in simplifyBinaryIntrinsic()
6508 if (Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6513 if (match(Op1, m_APIntAllowPoison(C))) { in simplifyBinaryIntrinsic()
6541 if (Value *V = foldMinMaxSharedOp(IID, Op0, Op1)) in simplifyBinaryIntrinsic()
6543 if (Value *V = foldMinMaxSharedOp(IID, Op1, Op0)) in simplifyBinaryIntrinsic()
6548 if (isICmpTrue(Pred, Op0, Op1, Q.getWithoutUndef(), RecursionLimit)) in simplifyBinaryIntrinsic()
6550 if (isICmpTrue(Pred, Op1, Op0, Q.getWithoutUndef(), RecursionLimit)) in simplifyBinaryIntrinsic()
6551 return Op1; in simplifyBinaryIntrinsic()
6559 if (isICmpTrue(CmpInst::ICMP_EQ, Op0, Op1, Q, RecursionLimit)) in simplifyBinaryIntrinsic()
6564 if (isICmpTrue(PredGT, Op0, Op1, Q, RecursionLimit)) in simplifyBinaryIntrinsic()
6569 if (isICmpTrue(PredLT, Op0, Op1, Q, RecursionLimit)) in simplifyBinaryIntrinsic()
6579 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6586 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) { in simplifyBinaryIntrinsic()
6597 if (match(Op0, m_Zero()) || match(Op1, m_Zero())) in simplifyBinaryIntrinsic()
6601 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6607 if (match(Op0, m_AllOnes()) || match(Op1, m_AllOnes())) in simplifyBinaryIntrinsic()
6615 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6619 if (match(Op1, m_Zero())) in simplifyBinaryIntrinsic()
6623 return Op1; in simplifyBinaryIntrinsic()
6627 if (match(Op0, m_Zero()) || match(Op1, m_AllOnes())) in simplifyBinaryIntrinsic()
6632 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6635 if (match(Op1, m_Zero())) in simplifyBinaryIntrinsic()
6640 if (auto *C1 = dyn_cast<Constant>(Op1)) in simplifyBinaryIntrinsic()
6644 if (auto *Power = dyn_cast<ConstantInt>(Op1)) { in simplifyBinaryIntrinsic()
6654 return simplifyLdexp(Op0, Op1, Q, false); in simplifyBinaryIntrinsic()
6657 if (Op0 == Op1) in simplifyBinaryIntrinsic()
6661 if (match(Op0, m_FNeg(m_Specific(Op1))) || in simplifyBinaryIntrinsic()
6662 match(Op1, m_FNeg(m_Specific(Op0)))) in simplifyBinaryIntrinsic()
6663 return Op1; in simplifyBinaryIntrinsic()
6669 uint64_t Mask = cast<ConstantInt>(Op1)->getZExtValue(); in simplifyBinaryIntrinsic()
6684 if (Op0 == Op1) in simplifyBinaryIntrinsic()
6689 std::swap(Op0, Op1); in simplifyBinaryIntrinsic()
6692 if (Q.isUndefValue(Op1)) in simplifyBinaryIntrinsic()
6702 if (match(Op1, m_NaN())) in simplifyBinaryIntrinsic()
6703 return PropagateNaN ? propagateNaN(cast<Constant>(Op1)) : Op0; in simplifyBinaryIntrinsic()
6708 if (match(Op1, m_APFloat(C)) && in simplifyBinaryIntrinsic()
6729 if (Value *V = foldMinimumMaximumSharedOp(IID, Op0, Op1)) in simplifyBinaryIntrinsic()
6731 if (Value *V = foldMinimumMaximumSharedOp(IID, Op1, Op0)) in simplifyBinaryIntrinsic()
6738 unsigned IdxN = cast<ConstantInt>(Op1)->getZExtValue(); in simplifyBinaryIntrinsic()
6799 Value *Op0 = Args[0], *Op1 = Args[1], *ShAmtArg = Args[2]; in simplifyIntrinsic() local
6802 if (Q.isUndefValue(Op0) && Q.isUndefValue(Op1)) in simplifyIntrinsic()
6818 if (match(Op0, m_Zero()) && match(Op1, m_Zero())) in simplifyIntrinsic()
6822 if (match(Op0, m_AllOnes()) && match(Op1, m_AllOnes())) in simplifyIntrinsic()
6844 Value *Op1 = Args[1]; in simplifyIntrinsic() local
6852 std::swap(Op0, Op1); in simplifyIntrinsic()
6855 if (match(Op1, m_Zero())) in simplifyIntrinsic()
6859 if (Q.isUndefValue(Op1)) in simplifyIntrinsic()
6866 if (ScaledOne.isNonNegative() && match(Op1, m_SpecificInt(ScaledOne))) in simplifyIntrinsic()