Lines Matching defs:Q
68 const SimplifyQuery &Q, unsigned MaxRecurse);
154 const SimplifyQuery &Q, unsigned MaxRecurse,
156 Value *SimplifiedCmp = simplifyCmpInst(Pred, LHS, RHS, Q, MaxRecurse);
171 const SimplifyQuery &Q,
173 return simplifyCmpSelCase(Pred, LHS, RHS, Cond, Q, MaxRecurse,
180 const SimplifyQuery &Q,
182 return simplifyCmpSelCase(Pred, LHS, RHS, Cond, Q, MaxRecurse,
190 const SimplifyQuery &Q,
199 if (Value *V = simplifyAndInst(Cond, TCmp, Q, MaxRecurse))
204 if (Value *V = simplifyOrInst(Cond, FCmp, Q, MaxRecurse))
210 Cond, Constant::getAllOnesValue(Cond->getType()), Q, MaxRecurse))
240 const SimplifyQuery &Q, unsigned MaxRecurse) {
246 simplifyBinOp(Opcode, B0, OtherOp, Q.getWithoutUndef(), MaxRecurse);
250 simplifyBinOp(Opcode, B1, OtherOp, Q.getWithoutUndef(), MaxRecurse);
262 Value *S = simplifyBinOp(OpcodeToExpand, L, R, Q, MaxRecurse);
275 const SimplifyQuery &Q,
281 if (Value *V = expandBinOp(Opcode, L, R, OpcodeToExpand, Q, MaxRecurse))
283 if (Value *V = expandBinOp(Opcode, R, L, OpcodeToExpand, Q, MaxRecurse))
292 const SimplifyQuery &Q,
310 if (Value *V = simplifyBinOp(Opcode, B, C, Q, MaxRecurse)) {
316 if (Value *W = simplifyBinOp(Opcode, A, V, Q, MaxRecurse)) {
330 if (Value *V = simplifyBinOp(Opcode, A, B, Q, MaxRecurse)) {
336 if (Value *W = simplifyBinOp(Opcode, V, C, Q, MaxRecurse)) {
354 if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) {
360 if (Value *W = simplifyBinOp(Opcode, V, B, Q, MaxRecurse)) {
374 if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) {
380 if (Value *W = simplifyBinOp(Opcode, B, V, Q, MaxRecurse)) {
395 Value *RHS, const SimplifyQuery &Q,
413 TV = simplifyBinOp(Opcode, SI->getTrueValue(), RHS, Q, MaxRecurse);
414 FV = simplifyBinOp(Opcode, SI->getFalseValue(), RHS, Q, MaxRecurse);
416 TV = simplifyBinOp(Opcode, LHS, SI->getTrueValue(), Q, MaxRecurse);
417 FV = simplifyBinOp(Opcode, LHS, SI->getFalseValue(), Q, MaxRecurse);
426 if (TV && Q.isUndefValue(TV))
428 if (FV && Q.isUndefValue(FV))
474 Value *RHS, const SimplifyQuery &Q,
493 Value *TCmp = simplifyCmpSelTrueCase(Pred, TV, RHS, Cond, Q, MaxRecurse);
498 Value *FCmp = simplifyCmpSelFalseCase(Pred, FV, RHS, Cond, Q, MaxRecurse);
510 return handleOtherCmpSelSimplifications(TCmp, FCmp, Cond, Q, MaxRecurse);
520 Value *RHS, const SimplifyQuery &Q,
530 if (!valueDominatesPHI(RHS, PI, Q.DT))
536 if (!valueDominatesPHI(LHS, PI, Q.DT))
549 Q.getWithInstruction(InTI), MaxRecurse)
551 Q.getWithInstruction(InTI), MaxRecurse);
567 const SimplifyQuery &Q, unsigned MaxRecurse) {
581 if (!valueDominatesPHI(RHS, PI, Q.DT))
595 Value *V = simplifyCmpInst(Pred, Incoming, RHS, Q.getWithInstruction(InTI),
609 const SimplifyQuery &Q) {
620 if (Q.CxtI != nullptr)
621 return ConstantFoldFPInstOperands(Opcode, CLHS, CRHS, Q.DL, Q.CxtI);
623 return ConstantFoldBinaryOpOperands(Opcode, CLHS, CRHS, Q.DL);
636 const SimplifyQuery &Q, unsigned MaxRecurse) {
637 if (Constant *C = foldOrCommuteConstant(Instruction::Add, Op0, Op1, Q))
645 if (Q.isUndefValue(Op1))
682 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1))
687 simplifyAssociativeBinOp(Instruction::Add, Op0, Op1, Q, MaxRecurse))
754 const SimplifyQuery &Q, unsigned MaxRecurse) {
760 isImpliedByDomCondition(CmpInst::ICMP_EQ, Op0, Op1, Q.CxtI, Q.DL);
788 const SimplifyQuery &Q, unsigned MaxRecurse) {
789 if (Constant *C = foldOrCommuteConstant(Instruction::Sub, Op0, Op1, Q))
799 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
816 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q);
833 if (Value *V = simplifyBinOp(Instruction::Sub, Y, Z, Q, MaxRecurse - 1))
835 if (Value *W = simplifyBinOp(Instruction::Add, X, V, Q, MaxRecurse - 1)) {
841 if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1))
843 if (Value *W = simplifyBinOp(Instruction::Add, Y, V, Q, MaxRecurse - 1)) {
855 if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1))
857 if (Value *W = simplifyBinOp(Instruction::Sub, V, Z, Q, MaxRecurse - 1)) {
863 if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1))
865 if (Value *W = simplifyBinOp(Instruction::Sub, V, Y, Q, MaxRecurse - 1)) {
877 if (Value *V = simplifyBinOp(Instruction::Sub, Z, X, Q, MaxRecurse - 1))
879 if (Value *W = simplifyBinOp(Instruction::Add, V, Y, Q, MaxRecurse - 1)) {
890 if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1))
893 Q, MaxRecurse - 1))
899 if (Constant *Result = computePointerDifference(Q.DL, X, Y))
901 Q.DL);
905 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1))
917 if (Value *V = simplifyByDomEq(Instruction::Sub, Op0, Op1, Q, MaxRecurse))
924 const SimplifyQuery &Q) {
925 return ::simplifySubInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
931 const SimplifyQuery &Q, unsigned MaxRecurse) {
932 if (Constant *C = foldOrCommuteConstant(Instruction::Mul, Op0, Op1, Q))
941 if (Q.isUndefValue(Op1) || match(Op1, m_Zero()))
950 if (Q.IIQ.UseInstrInfo &&
964 if (Value *V = simplifyAndInst(Op0, Op1, Q, MaxRecurse - 1))
970 simplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
975 Instruction::Add, Q, MaxRecurse))
982 threadBinOpOverSelect(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
989 threadBinOpOverPHI(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
996 const SimplifyQuery &Q) {
997 return ::simplifyMulInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
1004 const SimplifyQuery &Q, unsigned MaxRecurse) {
1005 Value *V = simplifyICmpInst(Pred, LHS, RHS, Q, MaxRecurse);
1012 static bool isDivZero(Value *X, Value *Y, const SimplifyQuery &Q,
1038 if (isICmpTrue(CmpInst::ICMP_SLT, Y, NegDividendC, Q, MaxRecurse) ||
1039 isICmpTrue(CmpInst::ICMP_SGT, Y, PosDividendC, Q, MaxRecurse))
1047 return isICmpTrue(CmpInst::ICMP_NE, X, Y, Q, MaxRecurse);
1054 if (isICmpTrue(CmpInst::ICMP_SGT, X, NegDivisorC, Q, MaxRecurse) &&
1055 isICmpTrue(CmpInst::ICMP_SLT, X, PosDivisorC, Q, MaxRecurse))
1068 computeKnownBits(X, /* Depth */ 0, Q).getMaxValue().ult(*C))
1073 return isICmpTrue(ICmpInst::ICMP_ULT, X, Y, Q, MaxRecurse);
1079 Value *Op1, const SimplifyQuery &Q,
1088 if (Q.isUndefValue(Op1) || isa<PoisonValue>(Op1))
1105 if (Elt && (Elt->isNullValue() || Q.isUndefValue(Elt)))
1117 if (Q.isUndefValue(Op0))
1130 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q);
1155 if ((IsSigned && Q.IIQ.hasNoSignedWrap(Mul)) ||
1156 (!IsSigned && Q.IIQ.hasNoUnsignedWrap(Mul)) ||
1163 if (isDivZero(Op0, Op1, Q, MaxRecurse, IsSigned))
1166 if (Value *V = simplifyByDomEq(Opcode, Op0, Op1, Q, MaxRecurse))
1172 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse))
1178 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse))
1186 bool IsExact, const SimplifyQuery &Q,
1188 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1191 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse))
1200 KnownBits KnownOp0 = computeKnownBits(Op0, /* Depth */ 0, Q);
1221 const SimplifyQuery &Q, unsigned MaxRecurse) {
1222 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1225 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse))
1229 if (Q.IIQ.UseInstrInfo) {
1258 const SimplifyQuery &Q, unsigned MaxRecurse) {
1263 return simplifyDiv(Instruction::SDiv, Op0, Op1, IsExact, Q, MaxRecurse);
1267 const SimplifyQuery &Q) {
1268 return ::simplifySDivInst(Op0, Op1, IsExact, Q, RecursionLimit);
1274 const SimplifyQuery &Q, unsigned MaxRecurse) {
1275 return simplifyDiv(Instruction::UDiv, Op0, Op1, IsExact, Q, MaxRecurse);
1279 const SimplifyQuery &Q) {
1280 return ::simplifyUDivInst(Op0, Op1, IsExact, Q, RecursionLimit);
1285 static Value *simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
1297 return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse);
1300 Value *llvm::simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
1301 return ::simplifySRemInst(Op0, Op1, Q, RecursionLimit);
1306 static Value *simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
1308 return simplifyRem(Instruction::URem, Op0, Op1, Q, MaxRecurse);
1311 Value *llvm::simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
1312 return ::simplifyURemInst(Op0, Op1, Q, RecursionLimit);
1316 static bool isPoisonShift(Value *Amount, const SimplifyQuery &Q) {
1322 if (Q.isUndefValue(C))
1337 if (!isPoisonShift(C->getAggregateElement(I), Q))
1348 Value *Op1, bool IsNSW, const SimplifyQuery &Q,
1350 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1370 if (isPoisonShift(Op1, Q))
1376 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse))
1382 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse))
1387 KnownBits KnownAmt = computeKnownBits(Op1, /* Depth */ 0, Q);
1400 KnownBits KnownVal = computeKnownBits(Op0, /* Depth */ 0, Q);
1419 const SimplifyQuery &Q, unsigned MaxRecurse) {
1421 simplifyShift(Opcode, Op0, Op1, /*IsNSW*/ false, Q, MaxRecurse))
1430 if (Q.isUndefValue(Op0))
1436 KnownBits Op0Known = computeKnownBits(Op0, /* Depth */ 0, Q);
1447 const SimplifyQuery &Q, unsigned MaxRecurse) {
1449 simplifyShift(Instruction::Shl, Op0, Op1, IsNSW, Q, MaxRecurse))
1455 if (Q.isUndefValue(Op0))
1460 if (Q.IIQ.UseInstrInfo &&
1481 const SimplifyQuery &Q) {
1482 return ::simplifyShlInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
1488 const SimplifyQuery &Q, unsigned MaxRecurse) {
1489 if (Value *V = simplifyRightShift(Instruction::LShr, Op0, Op1, IsExact, Q,
1495 if (Q.IIQ.UseInstrInfo && match(Op0, m_NUWShl(m_Value(X), m_Specific(Op1))))
1505 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(ShRAmt)) &&
1508 const KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
1518 const SimplifyQuery &Q) {
1519 return ::simplifyLShrInst(Op0, Op1, IsExact, Q, RecursionLimit);
1525 const SimplifyQuery &Q, unsigned MaxRecurse) {
1526 if (Value *V = simplifyRightShift(Instruction::AShr, Op0, Op1, IsExact, Q,
1539 if (Q.IIQ.UseInstrInfo && match(Op0, m_NSWShl(m_Value(X), m_Specific(Op1))))
1543 unsigned NumSignBits = ComputeNumSignBits(Op0, Q.DL, 0, Q.AC, Q.CxtI, Q.DT);
1551 const SimplifyQuery &Q) {
1552 return ::simplifyAShrInst(Op0, Op1, IsExact, Q, RecursionLimit);
1559 const SimplifyQuery &Q) {
1605 EqPred == ICmpInst::ICMP_NE && isKnownNonZero(B, Q))
1608 EqPred == ICmpInst::ICMP_EQ && isKnownNonZero(B, Q))
1626 isKnownNonZero(X, Q))
1632 isKnownNonZero(X, Q))
1772 const SimplifyQuery &Q) {
1773 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/true, Q))
1775 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/true, Q))
1786 if (Value *X = simplifyAndOfICmpsWithAdd(Op0, Op1, Q.IIQ))
1788 if (Value *X = simplifyAndOfICmpsWithAdd(Op1, Op0, Q.IIQ))
1842 const SimplifyQuery &Q) {
1843 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/false, Q))
1845 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/false, Q))
1856 if (Value *X = simplifyOrOfICmpsWithAdd(Op0, Op1, Q.IIQ))
1858 if (Value *X = simplifyOrOfICmpsWithAdd(Op1, Op0, Q.IIQ))
1864 static Value *simplifyAndOrOfFCmps(const SimplifyQuery &Q, FCmpInst *LHS,
1901 static Value *simplifyAndOrOfCmps(const SimplifyQuery &Q, Value *Op0,
1916 V = IsAnd ? simplifyAndOfICmps(ICmp0, ICmp1, Q)
1917 : simplifyOrOfICmps(ICmp0, ICmp1, Q);
1922 V = simplifyAndOrOfFCmps(Q, FCmp0, FCmp1, IsAnd);
1933 Q.DL);
1939 const SimplifyQuery &Q,
1945 const SimplifyQuery &Q,
1981 if (Value *Res = simplifyWithOpReplaced(Op1, A, B, Q.getWithoutUndef(),
1985 if (Value *Res = simplifyWithOpReplaced(Op1, B, A, Q.getWithoutUndef(),
2019 const SimplifyQuery &Q,
2043 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT))
2049 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT))
2057 isKnownToBeAPowerOfTwo(X, Q.DL, /*OrZero*/ true, /*Depth*/ 0, Q.AC,
2058 Q.CxtI) &&
2063 simplifyAndOrWithICmpEq(Instruction::And, Op0, Op1, Q, MaxRecurse))
2071 static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2073 if (Constant *C = foldOrCommuteConstant(Instruction::And, Op0, Op1, Q))
2081 if (Q.isUndefValue(Op1))
2096 if (Value *Res = simplifyAndCommutative(Op0, Op1, Q, MaxRecurse))
2098 if (Value *Res = simplifyAndCommutative(Op1, Op0, Q, MaxRecurse))
2127 isKnownToBeAPowerOfTwo(Shift, Q.DL, /*OrZero*/ false, 0, Q.AC, Q.CxtI,
2128 Q.DT)) {
2129 KnownBits Known = computeKnownBits(Shift, /* Depth */ 0, Q);
2135 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, true))
2140 simplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q, MaxRecurse))
2145 Instruction::Or, Q, MaxRecurse))
2150 Instruction::Xor, Q, MaxRecurse))
2165 threadBinOpOverSelect(Instruction::And, Op0, Op1, Q, MaxRecurse))
2173 threadBinOpOverPHI(Instruction::And, Op0, Op1, Q, MaxRecurse))
2187 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(Mask)) &&
2193 const KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
2196 const KnownBits XKnown = computeKnownBits(X, /* Depth */ 0, Q);
2226 if (std::optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL)) {
2234 if (std::optional<bool> Implied = isImpliedCondition(Op1, Op0, Q.DL)) {
2244 if (Value *V = simplifyByDomEq(Instruction::And, Op0, Op1, Q, MaxRecurse))
2250 Value *llvm::simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2251 return ::simplifyAndInst(Op0, Op1, Q, RecursionLimit);
2346 static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2348 if (Constant *C = foldOrCommuteConstant(Instruction::Or, Op0, Op1, Q))
2358 if (Q.isUndefValue(Op1) || match(Op1, m_AllOnes()))
2417 simplifyAndOrWithICmpEq(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2420 simplifyAndOrWithICmpEq(Instruction::Or, Op1, Op0, Q, MaxRecurse))
2423 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, false))
2436 simplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2441 Instruction::And, Q, MaxRecurse))
2456 threadBinOpOverSelect(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2474 if (MaskedValueIsZero(N, *C2, Q))
2480 if (MaskedValueIsZero(N, *C1, Q))
2489 if (Value *V = threadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2499 isImpliedCondition(Op0, Op1, Q.DL, false)) {
2508 isImpliedCondition(Op1, Op0, Q.DL, false)) {
2518 if (Value *V = simplifyByDomEq(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2524 Value *llvm::simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2525 return ::simplifyOrInst(Op0, Op1, Q, RecursionLimit);
2530 static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2532 if (Constant *C = foldOrCommuteConstant(Instruction::Xor, Op0, Op1, Q))
2540 if (Q.isUndefValue(Op1))
2583 simplifyAssociativeBinOp(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
2595 if (Value *V = simplifyByDomEq(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
2601 Value *llvm::simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2602 return ::simplifyXorInst(Op0, Op1, Q, RecursionLimit);
2722 Value *RHS, const SimplifyQuery &Q) {
2724 const DataLayout &DL = Q.DL;
2725 const TargetLibraryInfo *TLI = Q.TLI;
2830 if (isAllocLikeFn(LHS, TLI) && llvm::isKnownNonZero(RHS, Q))
2832 else if (isAllocLikeFn(RHS, TLI) && llvm::isKnownNonZero(LHS, Q))
2871 Value *RHS, const SimplifyQuery &Q) {
2944 if (isImpliedCondition(RHS, LHS, Q.DL).value_or(false))
2955 if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
2959 if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
2964 if (isImpliedCondition(RHS, LHS, Q.DL).value_or(false))
2974 Value *RHS, const SimplifyQuery &Q) {
2988 if (isKnownNonZero(LHS, Q))
2993 if (isKnownNonZero(LHS, Q))
2997 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
3005 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
3008 if (LHSKnown.isNonNegative() && isKnownNonZero(LHS, Q))
3013 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
3021 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
3024 if (LHSKnown.isNonNegative() && isKnownNonZero(LHS, Q))
3083 const SimplifyQuery &Q,
3096 KnownBits RHSKnown = computeKnownBits(RHS, /* Depth */ 0, Q);
3097 KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
3120 KnownBits Known = computeKnownBits(RHS, /* Depth */ 0, Q);
3131 KnownBits Known = computeKnownBits(RHS, /* Depth */ 0, Q);
3177 if (isKnownNonZero(RHS, Q)) {
3264 Value *RHS, const SimplifyQuery &Q,
3279 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(LBO))) ||
3281 Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(LBO)));
3289 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(RBO))) ||
3291 Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(RBO)));
3297 Constant::getNullValue(RHS->getType()), Q,
3305 C == LHS ? D : C, Q, MaxRecurse - 1))
3310 trySimplifyICmpWithAdds(Pred, LHS, RHS, Q.IIQ);
3332 if (Value *V = simplifyICmpInst(Pred, Y, Z, Q, MaxRecurse - 1))
3338 if (Value *V = simplifyICmpWithBinOpOnLHS(Pred, LBO, RHS, Q, MaxRecurse))
3343 ICmpInst::getSwappedPredicate(Pred), RBO, LHS, Q, MaxRecurse))
3379 if (Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(LBO)) ||
3380 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(LBO)) ||
3407 bool NUW = Q.IIQ.hasNoUnsignedWrap(LBO) && Q.IIQ.hasNoUnsignedWrap(RBO);
3408 bool NSW = Q.IIQ.hasNoSignedWrap(LBO) && Q.IIQ.hasNoSignedWrap(RBO);
3410 !isKnownNonZero(LBO->getOperand(0), Q))
3413 RBO->getOperand(1), Q, MaxRecurse - 1))
3456 if (ICmpInst::isSigned(Pred) || !Q.IIQ.isExact(LBO) ||
3457 !Q.IIQ.isExact(RBO))
3460 RBO->getOperand(0), Q, MaxRecurse - 1))
3464 if (!ICmpInst::isEquality(Pred) || !Q.IIQ.isExact(LBO) ||
3465 !Q.IIQ.isExact(RBO))
3468 RBO->getOperand(0), Q, MaxRecurse - 1))
3472 if (!Q.IIQ.isExact(LBO) || !Q.IIQ.isExact(RBO))
3475 RBO->getOperand(0), Q, MaxRecurse - 1))
3479 bool NUW = Q.IIQ.hasNoUnsignedWrap(LBO) && Q.IIQ.hasNoUnsignedWrap(RBO);
3480 bool NSW = Q.IIQ.hasNoSignedWrap(LBO) && Q.IIQ.hasNoSignedWrap(RBO);
3486 RBO->getOperand(0), Q, MaxRecurse - 1))
3498 Value *RHS, const SimplifyQuery &Q,
3551 if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1))
3565 if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1))
3625 if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1))
3639 if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1))
3684 const SimplifyQuery &Q) {
3686 if (!Q.AC || !Q.CxtI)
3690 for (auto &AssumeVH : Q.AC->assumptionsFor(AssumeBaseOp)) {
3696 Assume->getArgOperand(0), Predicate, LHS, RHS, Q.DL))
3697 if (isValidAssumeForContext(Assume, Q.CxtI, Q.DT))
3753 const SimplifyQuery &Q, unsigned MaxRecurse) {
3759 return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, Q.DL, Q.TLI);
3776 if (Q.isUndefValue(RHS) && ICmpInst::isEquality(Pred))
3781 if (LHS == RHS || Q.isUndefValue(RHS))
3784 if (Value *V = simplifyICmpOfBools(Pred, LHS, RHS, Q))
3789 if (Value *V = simplifyICmpWithZero(Pred, LHS, RHS, Q))
3792 if (Value *V = simplifyICmpWithConstant(Pred, LHS, RHS, Q.IIQ))
3797 if (std::optional<ConstantRange> RhsCr = getRange(RHS, Q.IIQ))
3798 if (std::optional<ConstantRange> LhsCr = getRange(LHS, Q.IIQ)) {
3816 Q.DL.getTypeSizeInBits(SrcTy) == DstTy->getPrimitiveSizeInBits()) {
3821 Q, MaxRecurse - 1))
3826 if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q,
3840 RI->getOperand(0), Q, MaxRecurse - 1))
3861 ConstantFoldCastOperand(Instruction::Trunc, C, SrcTy, Q.DL);
3864 ConstantFoldCastOperand(CastInst::ZExt, Trunc, DstTy, Q.DL);
3867 ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, RExt, C, Q.DL);
3875 SrcOp, Trunc, Q, MaxRecurse - 1))
3901 Q.DL);
3906 Q.DL);
3918 if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q,
3939 ConstantFoldCastOperand(Instruction::Trunc, C, SrcTy, Q.DL);
3942 ConstantFoldCastOperand(CastInst::SExt, Trunc, DstTy, Q.DL);
3945 ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, RExt, C, Q.DL);
3952 simplifyICmpInst(Pred, SrcOp, Trunc, Q, MaxRecurse - 1))
3972 Q.DL);
3977 Q.DL);
3986 Constant::getNullValue(SrcTy), Q,
3995 Constant::getNullValue(SrcTy), Q,
4009 isKnownNonEqual(LHS, RHS, Q.DL, Q.AC, Q.CxtI, Q.DT, Q.IIQ.UseInstrInfo)) {
4013 if (Value *V = simplifyICmpWithBinOp(Pred, LHS, RHS, Q, MaxRecurse))
4016 if (Value *V = simplifyICmpWithMinMax(Pred, LHS, RHS, Q, MaxRecurse))
4025 if (Value *V = simplifyICmpWithDominatingAssume(Pred, LHS, RHS, Q))
4029 isImpliedByDomCondition(Pred, LHS, RHS, Q.CxtI, Q.DL))
4035 if (auto *C = computePointerICmp(Pred, LHS, RHS, Q))
4040 Q.DL.getTypeSizeInBits(CLHS->getPointerOperandType()) ==
4041 Q.DL.getTypeSizeInBits(CLHS->getType()))
4043 CRHS->getPointerOperand(), Q))
4049 if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse))
4055 if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse))
4062 const SimplifyQuery &Q) {
4063 return ::simplifyICmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
4069 FastMathFlags FMF, const SimplifyQuery &Q,
4076 return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, Q.DL, Q.TLI,
4077 Q.CxtI);
4098 if (Q.isUndefValue(LHS) || Q.isUndefValue(RHS)) {
4118 computeKnownFPClass(RHS, fcAllFlags, /*Depth=*/0, Q);
4120 computeKnownFPClass(LHS, fcAllFlags, /*Depth=*/0, Q);
4140 return computeKnownFPClass(LHS, FMF, InterestedFlags, 0, Q);
4143 if (C && Q.CxtI) {
4149 const Function *ParentF = Q.CxtI->getFunction();
4284 if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse))
4290 if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse))
4297 FastMathFlags FMF, const SimplifyQuery &Q) {
4298 return ::simplifyFCmpInst(Predicate, LHS, RHS, FMF, Q, RecursionLimit);
4302 const SimplifyQuery &Q,
4306 assert((AllowRefinement || !Q.CanUseUndef) &&
4350 InstOp, Op, RepOp, Q, AllowRefinement, DropFlags, MaxRecurse)) {
4359 if (isa<UndefValue>(NewOps.back()) && !Q.CanUseUndef)
4436 ::simplifyInstructionWithOperands(I, NewOps, Q, MaxRecurse));
4468 Constant *Res = ConstantFoldInstOperands(I, ConstOps, Q.DL, Q.TLI);
4474 return ConstantFoldInstOperands(I, ConstOps, Q.DL, Q.TLI);
4478 const SimplifyQuery &Q,
4484 return ::simplifyWithOpReplaced(V, Op, RepOp, Q.getWithoutUndef(),
4486 return ::simplifyWithOpReplaced(V, Op, RepOp, Q, AllowRefinement, DropFlags,
4623 const SimplifyQuery &Q,
4625 if (simplifyWithOpReplaced(FalseVal, CmpLHS, CmpRHS, Q.getWithoutUndef(),
4629 if (simplifyWithOpReplaced(TrueVal, CmpLHS, CmpRHS, Q,
4641 const SimplifyQuery &Q,
4726 Q, MaxRecurse))
4729 Q, MaxRecurse))
4738 if (Value *V = simplifySelectWithICmpEq(X, CmpRHS, TrueVal, FalseVal, Q,
4741 if (Value *V = simplifySelectWithICmpEq(Y, CmpRHS, TrueVal, FalseVal, Q,
4750 if (Value *V = simplifySelectWithICmpEq(X, CmpRHS, TrueVal, FalseVal, Q,
4753 if (Value *V = simplifySelectWithICmpEq(Y, CmpRHS, TrueVal, FalseVal, Q,
4765 const SimplifyQuery &Q) {
4775 Q.CxtI && isa<FPMathOperator>(Q.CxtI) && Q.CxtI->hasNoSignedZeros();
4796 const SimplifyQuery &Q, unsigned MaxRecurse) {
4808 if (Q.isUndefValue(CondC))
4915 (Q.isUndefValue(TrueVal) && impliesPoison(FalseVal, Cond)))
4920 (Q.isUndefValue(FalseVal) && impliesPoison(TrueVal, Cond)))
4943 (Q.isUndefValue(TEltC) && isGuaranteedNotToBePoison(FEltC)))
4946 (Q.isUndefValue(FEltC) && isGuaranteedNotToBePoison(TEltC)))
4956 simplifySelectWithICmpCond(Cond, TrueVal, FalseVal, Q, MaxRecurse))
4959 if (Value *V = simplifySelectWithFCmp(Cond, TrueVal, FalseVal, Q))
4965 std::optional<bool> Imp = isImpliedByDomCondition(Cond, Q.CxtI, Q.DL);
4973 const SimplifyQuery &Q) {
4974 return ::simplifySelectInst(Cond, TrueVal, FalseVal, Q, RecursionLimit);
4981 const SimplifyQuery &Q, unsigned) {
5016 if (Q.isUndefValue(Ptr))
5029 uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty);
5037 Q.DL.getPointerSizeInBits(AS)) {
5068 if (!IsScalableVec && Q.DL.getTypeAllocSize(LastType) == 1 &&
5072 Q.DL.getIndexSizeInBits(Ptr->getType()->getPointerAddressSpace());
5073 if (Q.DL.getTypeSizeInBits(Indices.back()->getType()) == IdxWidth) {
5076 Ptr->stripAndAccumulateInBoundsConstantOffsets(Q.DL, BasePtrOffset);
5110 return ConstantFoldConstant(CE, Q.DL);
5114 GEPNoWrapFlags NW, const SimplifyQuery &Q) {
5115 return ::simplifyGEPInst(SrcTy, Ptr, Indices, NW, Q, RecursionLimit);
5122 const SimplifyQuery &Q, unsigned) {
5130 (Q.isUndefValue(Val) && isGuaranteedNotToBePoison(Agg)))
5140 (Q.isUndefValue(Agg) &&
5154 const SimplifyQuery &Q) {
5155 return ::simplifyInsertValueInst(Agg, Val, Idxs, Q, RecursionLimit);
5159 const SimplifyQuery &Q) {
5175 if (Q.isUndefValue(Idx))
5181 (Q.isUndefValue(Val) && isGuaranteedNotToBePoison(Vec)))
5219 const SimplifyQuery &Q) {
5220 return ::simplifyExtractValueInst(Agg, Idxs, Q, RecursionLimit);
5226 const SimplifyQuery &Q, unsigned) {
5232 if (Q.isUndefValue(Vec))
5238 if (Q.isUndefValue(Idx))
5271 const SimplifyQuery &Q) {
5272 return ::simplifyExtractElementInst(Vec, Idx, Q, RecursionLimit);
5277 const SimplifyQuery &Q) {
5295 if (Q.isUndefValue(Incoming)) {
5315 return valueDominatesPHI(CommonValue, PN, Q.DT) ? CommonValue : nullptr;
5322 const SimplifyQuery &Q, unsigned MaxRecurse) {
5324 return ConstantFoldCastOperand(CastOpc, C, Ty, Q.DL);
5335 SrcTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(SrcTy) : nullptr;
5337 MidTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(MidTy) : nullptr;
5339 DstTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(DstTy) : nullptr;
5357 X->getType() == Ty && Ty == Q.DL.getIndexType(Ptr->getType()))
5364 const SimplifyQuery &Q) {
5365 return ::simplifyCastInst(CastOpc, Op, Ty, Q, RecursionLimit);
5418 const SimplifyQuery &Q,
5498 if (Q.isUndefValue(Op1) && RetTy == InVecTy &&
5534 const SimplifyQuery &Q) {
5535 return ::simplifyShuffleVectorInst(Op0, Op1, Mask, RetTy, Q, RecursionLimit);
5539 const SimplifyQuery &Q) {
5541 return ConstantFoldUnaryOpOperand(Opcode, C, Q.DL);
5548 const SimplifyQuery &Q, unsigned MaxRecurse) {
5549 if (Constant *C = foldConstant(Instruction::FNeg, Op, Q))
5561 const SimplifyQuery &Q) {
5562 return ::simplifyFNegInst(Op, FMF, Q, RecursionLimit);
5610 const SimplifyQuery &Q,
5621 bool IsUndef = Q.isUndefValue(V);
5652 const SimplifyQuery &Q, unsigned MaxRecurse,
5656 if (Constant *C = foldOrCommuteConstant(Instruction::FAdd, Op0, Op1, Q))
5659 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5676 (FMF.noSignedZeros() || cannotBeNegativeZero(Op0, /*Depth=*/0, Q)))
5718 const SimplifyQuery &Q, unsigned MaxRecurse,
5722 if (Constant *C = foldOrCommuteConstant(Instruction::FSub, Op0, Op1, Q))
5725 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5738 (FMF.noSignedZeros() || cannotBeNegativeZero(Op0, /*Depth=*/0, Q)))
5770 return foldConstant(Instruction::FNeg, Op1, Q);
5784 const SimplifyQuery &Q, unsigned MaxRecurse,
5787 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5807 computeKnownFPClass(Op0, FMF, fcInf | fcNan, /*Depth=*/0, Q);
5814 return foldConstant(Instruction::FNeg, Op1, Q);
5833 const SimplifyQuery &Q, unsigned MaxRecurse,
5837 if (Constant *C = foldOrCommuteConstant(Instruction::FMul, Op0, Op1, Q))
5841 return simplifyFMAFMul(Op0, Op1, FMF, Q, MaxRecurse, ExBehavior, Rounding);
5845 const SimplifyQuery &Q,
5848 return ::simplifyFAddInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5853 const SimplifyQuery &Q,
5856 return ::simplifyFSubInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5861 const SimplifyQuery &Q,
5864 return ::simplifyFMulInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5869 const SimplifyQuery &Q,
5872 return ::simplifyFMAFMul(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5878 const SimplifyQuery &Q, unsigned,
5882 if (Constant *C = foldOrCommuteConstant(Instruction::FDiv, Op0, Op1, Q))
5885 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5928 const SimplifyQuery &Q,
5931 return ::simplifyFDivInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5937 const SimplifyQuery &Q, unsigned,
5941 if (Constant *C = foldOrCommuteConstant(Instruction::FRem, Op0, Op1, Q))
5944 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5966 const SimplifyQuery &Q,
5969 return ::simplifyFRemInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5977 static Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q,
5981 return simplifyFNegInst(Op, FastMathFlags(), Q, MaxRecurse);
5991 const FastMathFlags &FMF, const SimplifyQuery &Q,
5995 return simplifyFNegInst(Op, FMF, Q, MaxRecurse);
5997 return simplifyUnOp(Opcode, Op, Q, MaxRecurse);
6001 Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q) {
6002 return ::simplifyUnOp(Opcode, Op, Q, RecursionLimit);
6006 const SimplifyQuery &Q) {
6007 return ::simplifyFPUnOp(Opcode, Op, FMF, Q, RecursionLimit);
6013 const SimplifyQuery &Q, unsigned MaxRecurse) {
6016 return simplifyAddInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6019 return simplifySubInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6022 return simplifyMulInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6025 return simplifySDivInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6027 return simplifyUDivInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6029 return simplifySRemInst(LHS, RHS, Q, MaxRecurse);
6031 return simplifyURemInst(LHS, RHS, Q, MaxRecurse);
6033 return simplifyShlInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6036 return simplifyLShrInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6038 return simplifyAShrInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6040 return simplifyAndInst(LHS, RHS, Q, MaxRecurse);
6042 return simplifyOrInst(LHS, RHS, Q, MaxRecurse);
6044 return simplifyXorInst(LHS, RHS, Q, MaxRecurse);
6046 return simplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6048 return simplifyFSubInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6050 return simplifyFMulInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6052 return simplifyFDivInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6054 return simplifyFRemInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6064 const FastMathFlags &FMF, const SimplifyQuery &Q,
6068 return simplifyFAddInst(LHS, RHS, FMF, Q, MaxRecurse);
6070 return simplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse);
6072 return simplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse);
6074 return simplifyFDivInst(LHS, RHS, FMF, Q, MaxRecurse);
6076 return simplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse);
6081 const SimplifyQuery &Q) {
6082 return ::simplifyBinOp(Opcode, LHS, RHS, Q, RecursionLimit);
6086 FastMathFlags FMF, const SimplifyQuery &Q) {
6087 return ::simplifyBinOp(Opcode, LHS, RHS, FMF, Q, RecursionLimit);
6092 const SimplifyQuery &Q, unsigned MaxRecurse) {
6094 return simplifyICmpInst(Predicate, LHS, RHS, Q, MaxRecurse);
6095 return simplifyFCmpInst(Predicate, LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6099 const SimplifyQuery &Q) {
6100 return ::simplifyCmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
6194 static Value *simplifyLdexp(Value *Op0, Value *Op1, const SimplifyQuery &Q,
6202 if (Q.isUndefValue(Op0))
6209 if (Q.isUndefValue(Op1))
6244 const SimplifyQuery &Q,
6268 if (computeKnownFPSignBit(Op0, /*Depth=*/0, Q) == false)
6283 if (isKnownToBeAPowerOfTwo(Op0, Q.DL, /*OrZero*/ false, 0, Q.AC, Q.CxtI,
6284 Q.DT))
6290 Q))
6431 const SimplifyQuery &Q,
6463 if (Q.isUndefValue(Op0) || match(Op0, m_Zero()))
6467 Q.DL.getIndexTypeSizeInBits(Op0->getType()) &&
6477 if (match(Op1, m_AllOnes()) || Q.isUndefValue(Op1))
6482 KnownBits PtrKnown = computeKnownBits(Op0, /*Depth=*/0, Q);
6489 Q.DL);
6508 if (Q.isUndefValue(Op1))
6548 if (isICmpTrue(Pred, Op0, Op1, Q.getWithoutUndef(), RecursionLimit))
6550 if (isICmpTrue(Pred, Op1, Op0, Q.getWithoutUndef(), RecursionLimit))
6559 if (isICmpTrue(CmpInst::ICMP_EQ, Op0, Op1, Q, RecursionLimit))
6564 if (isICmpTrue(PredGT, Op0, Op1, Q, RecursionLimit))
6569 if (isICmpTrue(PredLT, Op0, Op1, Q, RecursionLimit))
6579 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6586 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) {
6601 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6615 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6632 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6641 return simplifyRelativeLoad(C0, C1, Q.DL);
6654 return simplifyLdexp(Op0, Op1, Q, false);
6675 if (Q.isUndefValue(Op0))
6692 if (Q.isUndefValue(Op1))
6756 const SimplifyQuery &Q) {
6780 return simplifyUnaryIntrinsic(F, Args[0], Q, Call);
6783 return simplifyBinaryIntrinsic(IID, F->getReturnType(), Args[0], Args[1], Q,
6802 if (Q.isUndefValue(Op0) && Q.isUndefValue(Op1))
6806 if (Q.isUndefValue(ShAmtArg))
6829 if (Value *V = simplifyFPOp(Args, {}, Q, *FPI->getExceptionBehavior(),
6836 if (Value *V = simplifyFPOp(Args, {}, Q, fp::ebIgnore,
6859 if (Q.isUndefValue(Op1))
6883 (Q.isUndefValue(Vec) || Vec == X) && IdxN == 0 &&
6891 return simplifyFAddInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6897 return simplifyFSubInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6903 return simplifyFMulInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6909 return simplifyFDivInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6915 return simplifyFRemInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6920 return simplifyLdexp(Args[0], Args[1], Q, true);
6949 const SimplifyQuery &Q) {
6966 return ConstantFoldCall(Call, F, ConstantArgs, Q.TLI);
6970 const SimplifyQuery &Q) {
6984 if (Value *V = tryConstantFoldCall(Call, Callee, Args, Q))
6989 if (Value *Ret = simplifyIntrinsic(Call, Callee, Args, Q))
6995 Value *llvm::simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q) {
6998 if (Value *V = tryConstantFoldCall(Call, Call->getCalledOperand(), Args, Q))
7000 if (Value *Ret = simplifyIntrinsic(Call, Call->getCalledOperand(), Args, Q))
7006 static Value *simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) {
7008 if (llvm::isGuaranteedNotToBeUndefOrPoison(Op0, Q.AC, Q.CxtI, Q.DT))
7014 Value *llvm::simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) {
7015 return ::simplifyFreezeInst(Op0, Q);
7019 const SimplifyQuery &Q) {
7024 return ConstantFoldLoadFromConstPtr(PtrOpC, LI->getType(), Q.DL);
7035 LI->getType(), Q.DL))
7040 APInt Offset(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()), 0);
7042 Q.DL, Offset, /* AllowNonInbounts */ true,
7046 Offset = Offset.sextOrTrunc(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()));
7048 Q.DL);
7065 const SimplifyQuery Q = SQ.CxtI ? SQ : SQ.getWithInstruction(I);
7073 return ConstantFoldInstOperands(I, NewConstOps, Q.DL, Q.TLI);
7077 return simplifyFNegInst(NewOps[0], I->getFastMathFlags(), Q, MaxRecurse);
7079 return simplifyFAddInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7083 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7084 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7086 return simplifyFSubInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7090 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7091 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7093 return simplifyFMulInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7097 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7098 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7101 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7105 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7108 return simplifyFDivInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7111 return simplifySRemInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7113 return simplifyURemInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7115 return simplifyFRemInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7119 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7120 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7123 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7127 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7130 return simplifyAndInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7132 return simplifyOrInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7134 return simplifyXorInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7137 NewOps[1], Q, MaxRecurse);
7140 NewOps[1], I->getFastMathFlags(), Q, MaxRecurse);
7142 return simplifySelectInst(NewOps[0], NewOps[1], NewOps[2], Q, MaxRecurse);
7147 ArrayRef(NewOps).slice(1), GEPI->getNoWrapFlags(), Q,
7152 return simplifyInsertValueInst(NewOps[0], NewOps[1], IV->getIndices(), Q,
7156 return simplifyInsertElementInst(NewOps[0], NewOps[1], NewOps[2], Q);
7159 return simplifyExtractValueInst(NewOps[0], EVI->getIndices(), Q,
7163 return simplifyExtractElementInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7167 SVI->getShuffleMask(), SVI->getType(), Q,
7171 return simplifyPHINode(cast<PHINode>(I), NewOps, Q);
7175 NewOps.drop_back(1 + cast<CallInst>(I)->getNumTotalBundleOperands()), Q);
7177 return llvm::simplifyFreezeInst(NewOps[0], Q);
7181 return simplifyCastInst(I->getOpcode(), NewOps[0], I->getType(), Q,
7187 return simplifyLoadInst(cast<LoadInst>(I), NewOps[0], Q);