Lines Matching defs:Q
69 const SimplifyQuery &Q, unsigned MaxRecurse);
111 Value *Cond, const SimplifyQuery &Q,
113 Value *SimplifiedCmp = simplifyCmpInst(Pred, LHS, RHS, Q, MaxRecurse);
127 Value *Cond, const SimplifyQuery &Q,
129 return simplifyCmpSelCase(Pred, LHS, RHS, Cond, Q, MaxRecurse,
135 Value *Cond, const SimplifyQuery &Q,
137 return simplifyCmpSelCase(Pred, LHS, RHS, Cond, Q, MaxRecurse,
145 const SimplifyQuery &Q,
154 if (Value *V = simplifyAndInst(Cond, TCmp, Q, MaxRecurse))
159 if (Value *V = simplifyOrInst(Cond, FCmp, Q, MaxRecurse))
165 Cond, Constant::getAllOnesValue(Cond->getType()), Q, MaxRecurse))
195 const SimplifyQuery &Q, unsigned MaxRecurse) {
201 simplifyBinOp(Opcode, B0, OtherOp, Q.getWithoutUndef(), MaxRecurse);
205 simplifyBinOp(Opcode, B1, OtherOp, Q.getWithoutUndef(), MaxRecurse);
217 Value *S = simplifyBinOp(OpcodeToExpand, L, R, Q, MaxRecurse);
230 const SimplifyQuery &Q,
236 if (Value *V = expandBinOp(Opcode, L, R, OpcodeToExpand, Q, MaxRecurse))
238 if (Value *V = expandBinOp(Opcode, R, L, OpcodeToExpand, Q, MaxRecurse))
247 const SimplifyQuery &Q,
265 if (Value *V = simplifyBinOp(Opcode, B, C, Q, MaxRecurse)) {
271 if (Value *W = simplifyBinOp(Opcode, A, V, Q, MaxRecurse)) {
285 if (Value *V = simplifyBinOp(Opcode, A, B, Q, MaxRecurse)) {
291 if (Value *W = simplifyBinOp(Opcode, V, C, Q, MaxRecurse)) {
309 if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) {
315 if (Value *W = simplifyBinOp(Opcode, V, B, Q, MaxRecurse)) {
329 if (Value *V = simplifyBinOp(Opcode, C, A, Q, MaxRecurse)) {
335 if (Value *W = simplifyBinOp(Opcode, B, V, Q, MaxRecurse)) {
350 Value *RHS, const SimplifyQuery &Q,
368 TV = simplifyBinOp(Opcode, SI->getTrueValue(), RHS, Q, MaxRecurse);
369 FV = simplifyBinOp(Opcode, SI->getFalseValue(), RHS, Q, MaxRecurse);
371 TV = simplifyBinOp(Opcode, LHS, SI->getTrueValue(), Q, MaxRecurse);
372 FV = simplifyBinOp(Opcode, LHS, SI->getFalseValue(), Q, MaxRecurse);
381 if (TV && Q.isUndefValue(TV))
383 if (FV && Q.isUndefValue(FV))
429 const SimplifyQuery &Q, unsigned MaxRecurse) {
447 Value *TCmp = simplifyCmpSelTrueCase(Pred, TV, RHS, Cond, Q, MaxRecurse);
452 Value *FCmp = simplifyCmpSelFalseCase(Pred, FV, RHS, Cond, Q, MaxRecurse);
464 return handleOtherCmpSelSimplifications(TCmp, FCmp, Cond, Q, MaxRecurse);
474 Value *RHS, const SimplifyQuery &Q,
484 if (!valueDominatesPHI(RHS, PI, Q.DT))
490 if (!valueDominatesPHI(LHS, PI, Q.DT))
503 Q.getWithInstruction(InTI), MaxRecurse)
505 Q.getWithInstruction(InTI), MaxRecurse);
521 const SimplifyQuery &Q, unsigned MaxRecurse) {
535 if (!valueDominatesPHI(RHS, PI, Q.DT))
549 Value *V = simplifyCmpInst(Pred, Incoming, RHS, Q.getWithInstruction(InTI),
563 const SimplifyQuery &Q) {
574 if (Q.CxtI != nullptr)
575 return ConstantFoldFPInstOperands(Opcode, CLHS, CRHS, Q.DL, Q.CxtI);
577 return ConstantFoldBinaryOpOperands(Opcode, CLHS, CRHS, Q.DL);
590 const SimplifyQuery &Q, unsigned MaxRecurse) {
591 if (Constant *C = foldOrCommuteConstant(Instruction::Add, Op0, Op1, Q))
599 if (Q.isUndefValue(Op1))
636 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1))
641 simplifyAssociativeBinOp(Instruction::Add, Op0, Op1, Q, MaxRecurse))
708 const SimplifyQuery &Q, unsigned MaxRecurse) {
714 isImpliedByDomCondition(CmpInst::ICMP_EQ, Op0, Op1, Q.CxtI, Q.DL);
742 const SimplifyQuery &Q, unsigned MaxRecurse) {
743 if (Constant *C = foldOrCommuteConstant(Instruction::Sub, Op0, Op1, Q))
753 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
770 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q);
787 if (Value *V = simplifyBinOp(Instruction::Sub, Y, Z, Q, MaxRecurse - 1))
789 if (Value *W = simplifyBinOp(Instruction::Add, X, V, Q, MaxRecurse - 1)) {
795 if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1))
797 if (Value *W = simplifyBinOp(Instruction::Add, Y, V, Q, MaxRecurse - 1)) {
809 if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1))
811 if (Value *W = simplifyBinOp(Instruction::Sub, V, Z, Q, MaxRecurse - 1)) {
817 if (Value *V = simplifyBinOp(Instruction::Sub, X, Z, Q, MaxRecurse - 1))
819 if (Value *W = simplifyBinOp(Instruction::Sub, V, Y, Q, MaxRecurse - 1)) {
831 if (Value *V = simplifyBinOp(Instruction::Sub, Z, X, Q, MaxRecurse - 1))
833 if (Value *W = simplifyBinOp(Instruction::Add, V, Y, Q, MaxRecurse - 1)) {
844 if (Value *V = simplifyBinOp(Instruction::Sub, X, Y, Q, MaxRecurse - 1))
847 Q, MaxRecurse - 1))
853 if (Constant *Result = computePointerDifference(Q.DL, X, Y))
855 Q.DL);
859 if (Value *V = simplifyXorInst(Op0, Op1, Q, MaxRecurse - 1))
871 if (Value *V = simplifyByDomEq(Instruction::Sub, Op0, Op1, Q, MaxRecurse))
886 const SimplifyQuery &Q) {
887 return ::simplifySubInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
893 const SimplifyQuery &Q, unsigned MaxRecurse) {
894 if (Constant *C = foldOrCommuteConstant(Instruction::Mul, Op0, Op1, Q))
903 if (Q.isUndefValue(Op1) || match(Op1, m_Zero()))
912 if (Q.IIQ.UseInstrInfo &&
926 if (Value *V = simplifyAndInst(Op0, Op1, Q, MaxRecurse - 1))
932 simplifyAssociativeBinOp(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
937 Instruction::Add, Q, MaxRecurse))
944 threadBinOpOverSelect(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
951 threadBinOpOverPHI(Instruction::Mul, Op0, Op1, Q, MaxRecurse))
958 const SimplifyQuery &Q) {
959 return ::simplifyMulInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
966 const SimplifyQuery &Q, unsigned MaxRecurse) {
967 Value *V = simplifyICmpInst(Pred, LHS, RHS, Q, MaxRecurse);
974 static bool isDivZero(Value *X, Value *Y, const SimplifyQuery &Q,
1000 if (isICmpTrue(CmpInst::ICMP_SLT, Y, NegDividendC, Q, MaxRecurse) ||
1001 isICmpTrue(CmpInst::ICMP_SGT, Y, PosDividendC, Q, MaxRecurse))
1009 return isICmpTrue(CmpInst::ICMP_NE, X, Y, Q, MaxRecurse);
1016 if (isICmpTrue(CmpInst::ICMP_SGT, X, NegDivisorC, Q, MaxRecurse) &&
1017 isICmpTrue(CmpInst::ICMP_SLT, X, PosDivisorC, Q, MaxRecurse))
1030 computeKnownBits(X, /* Depth */ 0, Q).getMaxValue().ult(*C))
1035 return isICmpTrue(ICmpInst::ICMP_ULT, X, Y, Q, MaxRecurse);
1041 Value *Op1, const SimplifyQuery &Q,
1050 if (Q.isUndefValue(Op1) || isa<PoisonValue>(Op1))
1066 if (Q.isUndefValue(Op0))
1079 KnownBits Known = computeKnownBits(Op1, /* Depth */ 0, Q);
1104 if ((IsSigned && Q.IIQ.hasNoSignedWrap(Mul)) ||
1105 (!IsSigned && Q.IIQ.hasNoUnsignedWrap(Mul)) ||
1112 if (isDivZero(Op0, Op1, Q, MaxRecurse, IsSigned))
1115 if (Value *V = simplifyByDomEq(Opcode, Op0, Op1, Q, MaxRecurse))
1121 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse))
1127 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse))
1135 bool IsExact, const SimplifyQuery &Q,
1137 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1140 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse))
1149 KnownBits KnownOp0 = computeKnownBits(Op0, /* Depth */ 0, Q);
1170 const SimplifyQuery &Q, unsigned MaxRecurse) {
1171 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1174 if (Value *V = simplifyDivRem(Opcode, Op0, Op1, Q, MaxRecurse))
1178 if (Q.IIQ.UseInstrInfo) {
1207 const SimplifyQuery &Q, unsigned MaxRecurse) {
1212 return simplifyDiv(Instruction::SDiv, Op0, Op1, IsExact, Q, MaxRecurse);
1216 const SimplifyQuery &Q) {
1217 return ::simplifySDivInst(Op0, Op1, IsExact, Q, RecursionLimit);
1223 const SimplifyQuery &Q, unsigned MaxRecurse) {
1224 return simplifyDiv(Instruction::UDiv, Op0, Op1, IsExact, Q, MaxRecurse);
1228 const SimplifyQuery &Q) {
1229 return ::simplifyUDivInst(Op0, Op1, IsExact, Q, RecursionLimit);
1234 static Value *simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
1246 return simplifyRem(Instruction::SRem, Op0, Op1, Q, MaxRecurse);
1249 Value *llvm::simplifySRemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
1250 return ::simplifySRemInst(Op0, Op1, Q, RecursionLimit);
1255 static Value *simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
1257 return simplifyRem(Instruction::URem, Op0, Op1, Q, MaxRecurse);
1260 Value *llvm::simplifyURemInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
1261 return ::simplifyURemInst(Op0, Op1, Q, RecursionLimit);
1265 static bool isPoisonShift(Value *Amount, const SimplifyQuery &Q) {
1271 if (Q.isUndefValue(C))
1286 if (!isPoisonShift(C->getAggregateElement(I), Q))
1297 Value *Op1, bool IsNSW, const SimplifyQuery &Q,
1299 if (Constant *C = foldOrCommuteConstant(Opcode, Op0, Op1, Q))
1319 if (isPoisonShift(Op1, Q))
1325 if (Value *V = threadBinOpOverSelect(Opcode, Op0, Op1, Q, MaxRecurse))
1331 if (Value *V = threadBinOpOverPHI(Opcode, Op0, Op1, Q, MaxRecurse))
1336 KnownBits KnownAmt = computeKnownBits(Op1, /* Depth */ 0, Q);
1349 KnownBits KnownVal = computeKnownBits(Op0, /* Depth */ 0, Q);
1368 const SimplifyQuery &Q, unsigned MaxRecurse) {
1370 simplifyShift(Opcode, Op0, Op1, /*IsNSW*/ false, Q, MaxRecurse))
1379 if (Q.isUndefValue(Op0))
1385 KnownBits Op0Known = computeKnownBits(Op0, /* Depth */ 0, Q);
1396 const SimplifyQuery &Q, unsigned MaxRecurse) {
1398 simplifyShift(Instruction::Shl, Op0, Op1, IsNSW, Q, MaxRecurse))
1404 if (Q.isUndefValue(Op0))
1409 if (Q.IIQ.UseInstrInfo &&
1430 const SimplifyQuery &Q) {
1431 return ::simplifyShlInst(Op0, Op1, IsNSW, IsNUW, Q, RecursionLimit);
1437 const SimplifyQuery &Q, unsigned MaxRecurse) {
1438 if (Value *V = simplifyRightShift(Instruction::LShr, Op0, Op1, IsExact, Q,
1444 if (Q.IIQ.UseInstrInfo && match(Op0, m_NUWShl(m_Value(X), m_Specific(Op1))))
1454 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(ShRAmt)) &&
1457 const KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
1467 const SimplifyQuery &Q) {
1468 return ::simplifyLShrInst(Op0, Op1, IsExact, Q, RecursionLimit);
1474 const SimplifyQuery &Q, unsigned MaxRecurse) {
1475 if (Value *V = simplifyRightShift(Instruction::AShr, Op0, Op1, IsExact, Q,
1488 if (Q.IIQ.UseInstrInfo && match(Op0, m_NSWShl(m_Value(X), m_Specific(Op1))))
1492 unsigned NumSignBits = ComputeNumSignBits(Op0, Q.DL, 0, Q.AC, Q.CxtI, Q.DT);
1500 const SimplifyQuery &Q) {
1501 return ::simplifyAShrInst(Op0, Op1, IsExact, Q, RecursionLimit);
1508 const SimplifyQuery &Q) {
1554 EqPred == ICmpInst::ICMP_NE && isKnownNonZero(B, Q))
1557 EqPred == ICmpInst::ICMP_EQ && isKnownNonZero(B, Q))
1575 isKnownNonZero(X, Q))
1581 isKnownNonZero(X, Q))
1721 const SimplifyQuery &Q) {
1722 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/true, Q))
1724 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/true, Q))
1735 if (Value *X = simplifyAndOfICmpsWithAdd(Op0, Op1, Q.IIQ))
1737 if (Value *X = simplifyAndOfICmpsWithAdd(Op1, Op0, Q.IIQ))
1791 const SimplifyQuery &Q) {
1792 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/false, Q))
1794 if (Value *X = simplifyUnsignedRangeCheck(Op1, Op0, /*IsAnd=*/false, Q))
1805 if (Value *X = simplifyOrOfICmpsWithAdd(Op0, Op1, Q.IIQ))
1807 if (Value *X = simplifyOrOfICmpsWithAdd(Op1, Op0, Q.IIQ))
1813 static Value *simplifyAndOrOfFCmps(const SimplifyQuery &Q, FCmpInst *LHS,
1854 static Value *simplifyAndOrOfCmps(const SimplifyQuery &Q, Value *Op0,
1869 V = IsAnd ? simplifyAndOfICmps(ICmp0, ICmp1, Q)
1870 : simplifyOrOfICmps(ICmp0, ICmp1, Q);
1875 V = simplifyAndOrOfFCmps(Q, FCmp0, FCmp1, IsAnd);
1886 Q.DL);
1892 const SimplifyQuery &Q,
1898 const SimplifyQuery &Q,
1934 if (Value *Res = simplifyWithOpReplaced(Op1, A, B, Q.getWithoutUndef(),
1938 if (Value *Res = simplifyWithOpReplaced(Op1, B, A, Q.getWithoutUndef(),
1972 const SimplifyQuery &Q,
1996 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT))
2002 isKnownToBeAPowerOfTwo(Op1, Q.DL, /*OrZero*/ true, 0, Q.AC, Q.CxtI, Q.DT))
2010 isKnownToBeAPowerOfTwo(X, Q.DL, /*OrZero*/ true, /*Depth*/ 0, Q.AC,
2011 Q.CxtI) &&
2016 simplifyAndOrWithICmpEq(Instruction::And, Op0, Op1, Q, MaxRecurse))
2024 static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2026 if (Constant *C = foldOrCommuteConstant(Instruction::And, Op0, Op1, Q))
2034 if (Q.isUndefValue(Op1))
2049 if (Value *Res = simplifyAndCommutative(Op0, Op1, Q, MaxRecurse))
2051 if (Value *Res = simplifyAndCommutative(Op1, Op0, Q, MaxRecurse))
2080 isKnownToBeAPowerOfTwo(Shift, Q.DL, /*OrZero*/ false, 0, Q.AC, Q.CxtI,
2081 Q.DT)) {
2082 KnownBits Known = computeKnownBits(Shift, /* Depth */ 0, Q);
2088 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, true))
2093 simplifyAssociativeBinOp(Instruction::And, Op0, Op1, Q, MaxRecurse))
2098 Instruction::Or, Q, MaxRecurse))
2103 Instruction::Xor, Q, MaxRecurse))
2118 threadBinOpOverSelect(Instruction::And, Op0, Op1, Q, MaxRecurse))
2126 threadBinOpOverPHI(Instruction::And, Op0, Op1, Q, MaxRecurse))
2140 if (Q.IIQ.UseInstrInfo && match(Op1, m_APInt(Mask)) &&
2146 const KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
2149 const KnownBits XKnown = computeKnownBits(X, /* Depth */ 0, Q);
2179 if (std::optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL)) {
2187 if (std::optional<bool> Implied = isImpliedCondition(Op1, Op0, Q.DL)) {
2197 if (Value *V = simplifyByDomEq(Instruction::And, Op0, Op1, Q, MaxRecurse))
2203 Value *llvm::simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2204 return ::simplifyAndInst(Op0, Op1, Q, RecursionLimit);
2299 static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2301 if (Constant *C = foldOrCommuteConstant(Instruction::Or, Op0, Op1, Q))
2311 if (Q.isUndefValue(Op1) || match(Op1, m_AllOnes()))
2370 simplifyAndOrWithICmpEq(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2373 simplifyAndOrWithICmpEq(Instruction::Or, Op1, Op0, Q, MaxRecurse))
2376 if (Value *V = simplifyAndOrOfCmps(Q, Op0, Op1, false))
2389 simplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2394 Instruction::And, Q, MaxRecurse))
2409 threadBinOpOverSelect(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2427 if (MaskedValueIsZero(N, *C2, Q))
2433 if (MaskedValueIsZero(N, *C1, Q))
2442 if (Value *V = threadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2452 isImpliedCondition(Op0, Op1, Q.DL, false)) {
2461 isImpliedCondition(Op1, Op0, Q.DL, false)) {
2471 if (Value *V = simplifyByDomEq(Instruction::Or, Op0, Op1, Q, MaxRecurse))
2477 Value *llvm::simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2478 return ::simplifyOrInst(Op0, Op1, Q, RecursionLimit);
2483 static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
2485 if (Constant *C = foldOrCommuteConstant(Instruction::Xor, Op0, Op1, Q))
2493 if (Q.isUndefValue(Op1))
2536 simplifyAssociativeBinOp(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
2548 if (Value *V = simplifyByDomEq(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
2562 Value *llvm::simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q) {
2563 return ::simplifyXorInst(Op0, Op1, Q, RecursionLimit);
2683 const SimplifyQuery &Q) {
2685 const DataLayout &DL = Q.DL;
2686 const TargetLibraryInfo *TLI = Q.TLI;
2791 if (isAllocLikeFn(LHS, TLI) && llvm::isKnownNonZero(RHS, Q))
2793 else if (isAllocLikeFn(RHS, TLI) && llvm::isKnownNonZero(LHS, Q))
2832 const SimplifyQuery &Q) {
2905 if (isImpliedCondition(RHS, LHS, Q.DL).value_or(false))
2916 if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
2920 if (isImpliedCondition(LHS, RHS, Q.DL).value_or(false))
2925 if (isImpliedCondition(RHS, LHS, Q.DL).value_or(false))
2935 const SimplifyQuery &Q) {
2949 if (isKnownNonZero(LHS, Q))
2954 if (isKnownNonZero(LHS, Q))
2958 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
2966 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
2969 if (LHSKnown.isNonNegative() && isKnownNonZero(LHS, Q))
2974 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
2982 KnownBits LHSKnown = computeKnownBits(LHS, /* Depth */ 0, Q);
2985 if (LHSKnown.isNonNegative() && isKnownNonZero(LHS, Q))
3106 Value *RHS, const SimplifyQuery &Q,
3114 KnownBits RHSKnown = computeKnownBits(RHS, /* Depth */ 0, Q);
3115 KnownBits YKnown = computeKnownBits(Y, /* Depth */ 0, Q);
3130 KnownBits Known = computeKnownBits(RHS, /* Depth */ 0, Q);
3141 KnownBits Known = computeKnownBits(RHS, /* Depth */ 0, Q);
3166 if (isKnownNonZero(RHS, Q)) {
3251 const SimplifyQuery &Q,
3266 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(LBO))) ||
3268 Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(LBO)));
3276 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(RBO))) ||
3278 Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(RBO)));
3284 Constant::getNullValue(RHS->getType()), Q,
3292 C == LHS ? D : C, Q, MaxRecurse - 1))
3297 trySimplifyICmpWithAdds(Pred, LHS, RHS, Q.IIQ);
3319 if (Value *V = simplifyICmpInst(Pred, Y, Z, Q, MaxRecurse - 1))
3325 if (Value *V = simplifyICmpWithBinOpOnLHS(Pred, LBO, RHS, Q, MaxRecurse))
3330 ICmpInst::getSwappedPredicate(Pred), RBO, LHS, Q, MaxRecurse))
3366 if (Q.IIQ.hasNoSignedWrap(cast<OverflowingBinaryOperator>(LBO)) ||
3367 Q.IIQ.hasNoUnsignedWrap(cast<OverflowingBinaryOperator>(LBO)) ||
3394 bool NUW = Q.IIQ.hasNoUnsignedWrap(LBO) && Q.IIQ.hasNoUnsignedWrap(RBO);
3395 bool NSW = Q.IIQ.hasNoSignedWrap(LBO) && Q.IIQ.hasNoSignedWrap(RBO);
3397 !isKnownNonZero(LBO->getOperand(0), Q))
3400 RBO->getOperand(1), Q, MaxRecurse - 1))
3443 if (ICmpInst::isSigned(Pred) || !Q.IIQ.isExact(LBO) ||
3444 !Q.IIQ.isExact(RBO))
3447 RBO->getOperand(0), Q, MaxRecurse - 1))
3451 if (!ICmpInst::isEquality(Pred) || !Q.IIQ.isExact(LBO) ||
3452 !Q.IIQ.isExact(RBO))
3455 RBO->getOperand(0), Q, MaxRecurse - 1))
3459 if (!Q.IIQ.isExact(LBO) || !Q.IIQ.isExact(RBO))
3462 RBO->getOperand(0), Q, MaxRecurse - 1))
3466 bool NUW = Q.IIQ.hasNoUnsignedWrap(LBO) && Q.IIQ.hasNoUnsignedWrap(RBO);
3467 bool NSW = Q.IIQ.hasNoSignedWrap(LBO) && Q.IIQ.hasNoSignedWrap(RBO);
3473 RBO->getOperand(0), Q, MaxRecurse - 1))
3485 const SimplifyQuery &Q,
3538 if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1))
3552 if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1))
3612 if (Value *V = simplifyICmpInst(EqP, A, B, Q, MaxRecurse - 1))
3626 if (Value *V = simplifyICmpInst(InvEqP, A, B, Q, MaxRecurse - 1))
3671 const SimplifyQuery &Q) {
3673 if (!Q.AC || !Q.CxtI)
3677 for (auto &AssumeVH : Q.AC->assumptionsFor(AssumeBaseOp)) {
3683 Assume->getArgOperand(0), Predicate, LHS, RHS, Q.DL))
3684 if (isValidAssumeForContext(Assume, Q.CxtI, Q.DT))
3742 const SimplifyQuery &Q, unsigned MaxRecurse) {
3747 return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, Q.DL, Q.TLI);
3764 if (Q.isUndefValue(RHS) && ICmpInst::isEquality(Pred))
3769 if (LHS == RHS || Q.isUndefValue(RHS))
3772 if (Value *V = simplifyICmpOfBools(Pred, LHS, RHS, Q))
3777 if (Value *V = simplifyICmpWithZero(Pred, LHS, RHS, Q))
3780 if (Value *V = simplifyICmpWithConstant(Pred, LHS, RHS, Q.IIQ))
3785 if (std::optional<ConstantRange> RhsCr = getRange(RHS, Q.IIQ))
3786 if (std::optional<ConstantRange> LhsCr = getRange(LHS, Q.IIQ)) {
3804 Q.DL.getTypeSizeInBits(SrcTy) == DstTy->getPrimitiveSizeInBits()) {
3809 Q, MaxRecurse - 1))
3814 if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q,
3828 RI->getOperand(0), Q, MaxRecurse - 1))
3849 ConstantFoldCastOperand(Instruction::Trunc, C, SrcTy, Q.DL);
3852 ConstantFoldCastOperand(CastInst::ZExt, Trunc, DstTy, Q.DL);
3855 ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, RExt, C, Q.DL);
3863 SrcOp, Trunc, Q, MaxRecurse - 1))
3889 Q.DL);
3894 Q.DL);
3906 if (Value *V = simplifyICmpInst(Pred, SrcOp, RI->getOperand(0), Q,
3927 ConstantFoldCastOperand(Instruction::Trunc, C, SrcTy, Q.DL);
3930 ConstantFoldCastOperand(CastInst::SExt, Trunc, DstTy, Q.DL);
3933 ConstantFoldCompareInstOperands(ICmpInst::ICMP_EQ, RExt, C, Q.DL);
3940 simplifyICmpInst(Pred, SrcOp, Trunc, Q, MaxRecurse - 1))
3960 Q.DL);
3965 Q.DL);
3974 Constant::getNullValue(SrcTy), Q,
3983 Constant::getNullValue(SrcTy), Q,
3997 isKnownNonEqual(LHS, RHS, Q.DL, Q.AC, Q.CxtI, Q.DT, Q.IIQ.UseInstrInfo)) {
4001 if (Value *V = simplifyICmpWithBinOp(Pred, LHS, RHS, Q, MaxRecurse))
4004 if (Value *V = simplifyICmpWithMinMax(Pred, LHS, RHS, Q, MaxRecurse))
4019 if (Value *V = simplifyICmpWithDominatingAssume(Pred, LHS, RHS, Q))
4023 isImpliedByDomCondition(Pred, LHS, RHS, Q.CxtI, Q.DL))
4029 if (auto *C = computePointerICmp(Pred, LHS, RHS, Q))
4034 Q.DL.getTypeSizeInBits(CLHS->getPointerOperandType()) ==
4035 Q.DL.getTypeSizeInBits(CLHS->getType()))
4037 CRHS->getPointerOperand(), Q))
4043 if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse))
4049 if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse))
4056 const SimplifyQuery &Q) {
4057 return ::simplifyICmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
4063 FastMathFlags FMF, const SimplifyQuery &Q,
4069 return ConstantFoldCompareInstOperands(Pred, CLHS, CRHS, Q.DL, Q.TLI,
4070 Q.CxtI);
4091 if (Q.isUndefValue(LHS) || Q.isUndefValue(RHS)) {
4111 computeKnownFPClass(RHS, fcAllFlags, /*Depth=*/0, Q);
4113 computeKnownFPClass(LHS, fcAllFlags, /*Depth=*/0, Q);
4133 return computeKnownFPClass(LHS, FMF, InterestedFlags, 0, Q);
4136 if (C && Q.CxtI) {
4142 const Function *ParentF = Q.CxtI->getFunction();
4277 if (Value *V = threadCmpOverSelect(Pred, LHS, RHS, Q, MaxRecurse))
4283 if (Value *V = threadCmpOverPHI(Pred, LHS, RHS, Q, MaxRecurse))
4290 FastMathFlags FMF, const SimplifyQuery &Q) {
4291 return ::simplifyFCmpInst(Predicate, LHS, RHS, FMF, Q, RecursionLimit);
4296 const SimplifyQuery &Q,
4300 assert((AllowRefinement || !Q.CanUseUndef) &&
4345 InstOp, Ops, Q, AllowRefinement, DropFlags, MaxRecurse)) {
4354 if (isa<UndefValue>(NewOps.back()) && !Q.CanUseUndef)
4435 ::simplifyInstructionWithOperands(I, NewOps, Q, MaxRecurse));
4467 Constant *Res = ConstantFoldInstOperands(I, ConstOps, Q.DL, Q.TLI,
4474 return ConstantFoldInstOperands(I, ConstOps, Q.DL, Q.TLI,
4479 const SimplifyQuery &Q,
4483 return simplifyWithOpsReplaced(V, {{Op, RepOp}}, Q, AllowRefinement,
4488 const SimplifyQuery &Q,
4494 return ::simplifyWithOpReplaced(V, Op, RepOp, Q.getWithoutUndef(),
4496 return ::simplifyWithOpReplaced(V, Op, RepOp, Q, AllowRefinement, DropFlags,
4631 Value *FalseVal, const SimplifyQuery &Q, unsigned MaxRecurse) {
4633 simplifyWithOpsReplaced(FalseVal, Replacements, Q.getWithoutUndef(),
4640 simplifyWithOpsReplaced(TrueVal, Replacements, Q,
4656 const SimplifyQuery &Q,
4741 FalseVal, Q, MaxRecurse))
4744 FalseVal, Q, MaxRecurse))
4754 {{X, CmpRHS}, {Y, CmpRHS}}, TrueVal, FalseVal, Q, MaxRecurse))
4763 {{X, CmpRHS}, {Y, CmpRHS}}, TrueVal, FalseVal, Q, MaxRecurse))
4774 const SimplifyQuery &Q,
4792 if (Value *V = simplifySelectWithEquivalence({{CmpLHS, CmpRHS}}, T, F, Q,
4795 if (Value *V = simplifySelectWithEquivalence({{CmpRHS, CmpLHS}}, T, F, Q,
4808 if (Q.CxtI && isa<FPMathOperator>(Q.CxtI) && Q.CxtI->hasNoSignedZeros()) {
4824 const SimplifyQuery &Q, unsigned MaxRecurse) {
4836 if (Q.isUndefValue(CondC))
4943 (Q.isUndefValue(TrueVal) && impliesPoison(FalseVal, Cond)))
4948 (Q.isUndefValue(FalseVal) && impliesPoison(TrueVal, Cond)))
4971 (Q.isUndefValue(TEltC) && isGuaranteedNotToBePoison(FEltC)))
4974 (Q.isUndefValue(FEltC) && isGuaranteedNotToBePoison(TEltC)))
4984 simplifySelectWithICmpCond(Cond, TrueVal, FalseVal, Q, MaxRecurse))
4987 if (Value *V = simplifySelectWithFCmp(Cond, TrueVal, FalseVal, Q, MaxRecurse))
4990 std::optional<bool> Imp = isImpliedByDomCondition(Cond, Q.CxtI, Q.DL);
4998 const SimplifyQuery &Q) {
4999 return ::simplifySelectInst(Cond, TrueVal, FalseVal, Q, RecursionLimit);
5006 const SimplifyQuery &Q, unsigned) {
5041 if (Q.isUndefValue(Ptr))
5054 uint64_t TyAllocSize = Q.DL.getTypeAllocSize(Ty);
5062 Q.DL.getPointerSizeInBits(AS)) {
5093 if (!IsScalableVec && Q.DL.getTypeAllocSize(LastType) == 1 &&
5097 Q.DL.getIndexSizeInBits(Ptr->getType()->getPointerAddressSpace());
5098 if (Q.DL.getTypeSizeInBits(Indices.back()->getType()) == IdxWidth) {
5101 Ptr->stripAndAccumulateInBoundsConstantOffsets(Q.DL, BasePtrOffset);
5135 return ConstantFoldConstant(CE, Q.DL);
5139 GEPNoWrapFlags NW, const SimplifyQuery &Q) {
5140 return ::simplifyGEPInst(SrcTy, Ptr, Indices, NW, Q, RecursionLimit);
5147 const SimplifyQuery &Q, unsigned) {
5155 (Q.isUndefValue(Val) && isGuaranteedNotToBePoison(Agg)))
5165 (Q.isUndefValue(Agg) &&
5179 const SimplifyQuery &Q) {
5180 return ::simplifyInsertValueInst(Agg, Val, Idxs, Q, RecursionLimit);
5184 const SimplifyQuery &Q) {
5200 if (Q.isUndefValue(Idx))
5206 (Q.isUndefValue(Val) && isGuaranteedNotToBePoison(Vec)))
5248 const SimplifyQuery &Q) {
5249 return ::simplifyExtractValueInst(Agg, Idxs, Q, RecursionLimit);
5255 const SimplifyQuery &Q, unsigned) {
5261 if (Q.isUndefValue(Vec))
5267 if (Q.isUndefValue(Idx))
5300 const SimplifyQuery &Q) {
5301 return ::simplifyExtractElementInst(Vec, Idx, Q, RecursionLimit);
5306 const SimplifyQuery &Q) {
5324 if (Q.isUndefValue(Incoming)) {
5344 if (!valueDominatesPHI(CommonValue, PN, Q.DT))
5349 !isGuaranteedNotToBePoison(CommonValue, Q.AC, Q.CxtI, Q.DT))
5358 const SimplifyQuery &Q, unsigned MaxRecurse) {
5360 return ConstantFoldCastOperand(CastOpc, C, Ty, Q.DL);
5371 SrcTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(SrcTy) : nullptr;
5373 MidTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(MidTy) : nullptr;
5375 DstTy->isPtrOrPtrVectorTy() ? Q.DL.getIntPtrType(DstTy) : nullptr;
5393 X->getType() == Ty && Ty == Q.DL.getIndexType(Ptr->getType()))
5400 const SimplifyQuery &Q) {
5401 return ::simplifyCastInst(CastOpc, Op, Ty, Q, RecursionLimit);
5454 const SimplifyQuery &Q,
5534 if (Q.isUndefValue(Op1) && RetTy == InVecTy &&
5570 const SimplifyQuery &Q) {
5571 return ::simplifyShuffleVectorInst(Op0, Op1, Mask, RetTy, Q, RecursionLimit);
5575 const SimplifyQuery &Q) {
5577 return ConstantFoldUnaryOpOperand(Opcode, C, Q.DL);
5584 const SimplifyQuery &Q, unsigned MaxRecurse) {
5585 if (Constant *C = foldConstant(Instruction::FNeg, Op, Q))
5597 const SimplifyQuery &Q) {
5598 return ::simplifyFNegInst(Op, FMF, Q, RecursionLimit);
5646 const SimplifyQuery &Q,
5657 bool IsUndef = Q.isUndefValue(V);
5688 const SimplifyQuery &Q, unsigned MaxRecurse,
5692 if (Constant *C = foldOrCommuteConstant(Instruction::FAdd, Op0, Op1, Q))
5695 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5712 (FMF.noSignedZeros() || cannotBeNegativeZero(Op0, /*Depth=*/0, Q)))
5754 const SimplifyQuery &Q, unsigned MaxRecurse,
5758 if (Constant *C = foldOrCommuteConstant(Instruction::FSub, Op0, Op1, Q))
5761 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5774 (FMF.noSignedZeros() || cannotBeNegativeZero(Op0, /*Depth=*/0, Q)))
5806 return foldConstant(Instruction::FNeg, Op1, Q);
5820 const SimplifyQuery &Q, unsigned MaxRecurse,
5823 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5843 computeKnownFPClass(Op0, FMF, fcInf | fcNan, /*Depth=*/0, Q);
5850 return foldConstant(Instruction::FNeg, Op1, Q);
5869 const SimplifyQuery &Q, unsigned MaxRecurse,
5873 if (Constant *C = foldOrCommuteConstant(Instruction::FMul, Op0, Op1, Q))
5877 return simplifyFMAFMul(Op0, Op1, FMF, Q, MaxRecurse, ExBehavior, Rounding);
5881 const SimplifyQuery &Q,
5884 return ::simplifyFAddInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5889 const SimplifyQuery &Q,
5892 return ::simplifyFSubInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5897 const SimplifyQuery &Q,
5900 return ::simplifyFMulInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5905 const SimplifyQuery &Q,
5908 return ::simplifyFMAFMul(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5914 const SimplifyQuery &Q, unsigned,
5918 if (Constant *C = foldOrCommuteConstant(Instruction::FDiv, Op0, Op1, Q))
5921 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
5964 const SimplifyQuery &Q,
5967 return ::simplifyFDivInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
5973 const SimplifyQuery &Q, unsigned,
5977 if (Constant *C = foldOrCommuteConstant(Instruction::FRem, Op0, Op1, Q))
5980 if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
6002 const SimplifyQuery &Q,
6005 return ::simplifyFRemInst(Op0, Op1, FMF, Q, RecursionLimit, ExBehavior,
6013 static Value *simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q,
6017 return simplifyFNegInst(Op, FastMathFlags(), Q, MaxRecurse);
6027 const FastMathFlags &FMF, const SimplifyQuery &Q,
6031 return simplifyFNegInst(Op, FMF, Q, MaxRecurse);
6033 return simplifyUnOp(Opcode, Op, Q, MaxRecurse);
6037 Value *llvm::simplifyUnOp(unsigned Opcode, Value *Op, const SimplifyQuery &Q) {
6038 return ::simplifyUnOp(Opcode, Op, Q, RecursionLimit);
6042 const SimplifyQuery &Q) {
6043 return ::simplifyFPUnOp(Opcode, Op, FMF, Q, RecursionLimit);
6049 const SimplifyQuery &Q, unsigned MaxRecurse) {
6052 return simplifyAddInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6055 return simplifySubInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6058 return simplifyMulInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6061 return simplifySDivInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6063 return simplifyUDivInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6065 return simplifySRemInst(LHS, RHS, Q, MaxRecurse);
6067 return simplifyURemInst(LHS, RHS, Q, MaxRecurse);
6069 return simplifyShlInst(LHS, RHS, /* IsNSW */ false, /* IsNUW */ false, Q,
6072 return simplifyLShrInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6074 return simplifyAShrInst(LHS, RHS, /* IsExact */ false, Q, MaxRecurse);
6076 return simplifyAndInst(LHS, RHS, Q, MaxRecurse);
6078 return simplifyOrInst(LHS, RHS, Q, MaxRecurse);
6080 return simplifyXorInst(LHS, RHS, Q, MaxRecurse);
6082 return simplifyFAddInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6084 return simplifyFSubInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6086 return simplifyFMulInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6088 return simplifyFDivInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6090 return simplifyFRemInst(LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6100 const FastMathFlags &FMF, const SimplifyQuery &Q,
6104 return simplifyFAddInst(LHS, RHS, FMF, Q, MaxRecurse);
6106 return simplifyFSubInst(LHS, RHS, FMF, Q, MaxRecurse);
6108 return simplifyFMulInst(LHS, RHS, FMF, Q, MaxRecurse);
6110 return simplifyFDivInst(LHS, RHS, FMF, Q, MaxRecurse);
6112 return simplifyBinOp(Opcode, LHS, RHS, Q, MaxRecurse);
6117 const SimplifyQuery &Q) {
6118 return ::simplifyBinOp(Opcode, LHS, RHS, Q, RecursionLimit);
6122 FastMathFlags FMF, const SimplifyQuery &Q) {
6123 return ::simplifyBinOp(Opcode, LHS, RHS, FMF, Q, RecursionLimit);
6128 const SimplifyQuery &Q, unsigned MaxRecurse) {
6130 return simplifyICmpInst(Predicate, LHS, RHS, Q, MaxRecurse);
6131 return simplifyFCmpInst(Predicate, LHS, RHS, FastMathFlags(), Q, MaxRecurse);
6135 const SimplifyQuery &Q) {
6136 return ::simplifyCmpInst(Predicate, LHS, RHS, Q, RecursionLimit);
6230 static Value *simplifyLdexp(Value *Op0, Value *Op1, const SimplifyQuery &Q,
6238 if (Q.isUndefValue(Op0))
6245 if (Q.isUndefValue(Op1))
6280 const SimplifyQuery &Q,
6304 if (computeKnownFPSignBit(Op0, /*Depth=*/0, Q) == false)
6319 if (isKnownToBeAPowerOfTwo(Op0, Q.DL, /*OrZero*/ false, 0, Q.AC, Q.CxtI,
6320 Q.DT))
6326 Q))
6467 const SimplifyQuery &Q,
6499 if (Q.isUndefValue(Op0) || match(Op0, m_Zero()))
6503 Q.DL.getIndexTypeSizeInBits(Op0->getType()) &&
6513 if (match(Op1, m_AllOnes()) || Q.isUndefValue(Op1))
6518 KnownBits PtrKnown = computeKnownBits(Op0, /*Depth=*/0, Q);
6525 Q.DL);
6544 if (Q.isUndefValue(Op1))
6584 if (isICmpTrue(Pred, Op0, Op1, Q.getWithoutUndef(), RecursionLimit))
6586 if (isICmpTrue(Pred, Op1, Op0, Q.getWithoutUndef(), RecursionLimit))
6595 if (isICmpTrue(CmpInst::ICMP_EQ, Op0, Op1, Q, RecursionLimit))
6600 if (isICmpTrue(PredGT, Op0, Op1, Q, RecursionLimit))
6605 if (isICmpTrue(PredLT, Op0, Op1, Q, RecursionLimit))
6615 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6622 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1)) {
6637 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6651 if (Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6668 if (Op0 == Op1 || Q.isUndefValue(Op0) || Q.isUndefValue(Op1))
6677 return simplifyRelativeLoad(C0, C1, Q.DL);
6690 return simplifyLdexp(Op0, Op1, Q, false);
6711 if (Q.isUndefValue(Op0))
6728 if (Q.isUndefValue(Op1))
6792 const SimplifyQuery &Q) {
6816 return simplifyUnaryIntrinsic(F, Args[0], Q, Call);
6819 return simplifyBinaryIntrinsic(IID, F->getReturnType(), Args[0], Args[1], Q,
6838 if (Q.isUndefValue(Op0) && Q.isUndefValue(Op1))
6842 if (Q.isUndefValue(ShAmtArg))
6865 if (Value *V = simplifyFPOp(Args, {}, Q, *FPI->getExceptionBehavior(),
6872 if (Value *V = simplifyFPOp(Args, {}, Q, fp::ebIgnore,
6895 if (Q.isUndefValue(Op1))
6919 (Q.isUndefValue(Vec) || Vec == X) && IdxN == 0 &&
6927 return simplifyFAddInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6933 return simplifyFSubInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6939 return simplifyFMulInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6945 return simplifyFDivInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6951 return simplifyFRemInst(Args[0], Args[1], FPI->getFastMathFlags(), Q,
6956 return simplifyLdexp(Args[0], Args[1], Q, true);
6985 const SimplifyQuery &Q) {
7002 return ConstantFoldCall(Call, F, ConstantArgs, Q.TLI);
7006 const SimplifyQuery &Q) {
7020 if (Value *V = tryConstantFoldCall(Call, Callee, Args, Q))
7025 if (Value *Ret = simplifyIntrinsic(Call, Callee, Args, Q))
7031 Value *llvm::simplifyConstrainedFPCall(CallBase *Call, const SimplifyQuery &Q) {
7034 if (Value *V = tryConstantFoldCall(Call, Call->getCalledOperand(), Args, Q))
7036 if (Value *Ret = simplifyIntrinsic(Call, Call->getCalledOperand(), Args, Q))
7042 static Value *simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) {
7044 if (llvm::isGuaranteedNotToBeUndefOrPoison(Op0, Q.AC, Q.CxtI, Q.DT))
7050 Value *llvm::simplifyFreezeInst(Value *Op0, const SimplifyQuery &Q) {
7051 return ::simplifyFreezeInst(Op0, Q);
7055 const SimplifyQuery &Q) {
7060 return ConstantFoldLoadFromConstPtr(PtrOpC, LI->getType(), Q.DL);
7071 LI->getType(), Q.DL))
7076 APInt Offset(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()), 0);
7078 Q.DL, Offset, /* AllowNonInbounts */ true,
7082 Offset = Offset.sextOrTrunc(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()));
7084 Q.DL);
7101 const SimplifyQuery Q = SQ.CxtI ? SQ : SQ.getWithInstruction(I);
7109 return ConstantFoldInstOperands(I, NewConstOps, Q.DL, Q.TLI);
7113 return simplifyFNegInst(NewOps[0], I->getFastMathFlags(), Q, MaxRecurse);
7115 return simplifyFAddInst(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);
7122 return simplifyFSubInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7126 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7127 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7129 return simplifyFMulInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7133 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7134 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7137 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7141 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7144 return simplifyFDivInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7147 return simplifySRemInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7149 return simplifyURemInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7151 return simplifyFRemInst(NewOps[0], NewOps[1], I->getFastMathFlags(), Q,
7155 NewOps[0], NewOps[1], Q.IIQ.hasNoSignedWrap(cast<BinaryOperator>(I)),
7156 Q.IIQ.hasNoUnsignedWrap(cast<BinaryOperator>(I)), Q, MaxRecurse);
7159 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7163 Q.IIQ.isExact(cast<BinaryOperator>(I)), Q,
7166 return simplifyAndInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7168 return simplifyOrInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7170 return simplifyXorInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7173 NewOps[1], Q, MaxRecurse);
7176 NewOps[1], I->getFastMathFlags(), Q, MaxRecurse);
7178 return simplifySelectInst(NewOps[0], NewOps[1], NewOps[2], Q, MaxRecurse);
7182 ArrayRef(NewOps).slice(1), GEPI->getNoWrapFlags(), Q,
7187 return simplifyInsertValueInst(NewOps[0], NewOps[1], IV->getIndices(), Q,
7191 return simplifyInsertElementInst(NewOps[0], NewOps[1], NewOps[2], Q);
7194 return simplifyExtractValueInst(NewOps[0], EVI->getIndices(), Q,
7198 return simplifyExtractElementInst(NewOps[0], NewOps[1], Q, MaxRecurse);
7202 SVI->getShuffleMask(), SVI->getType(), Q,
7206 return simplifyPHINode(cast<PHINode>(I), NewOps, Q);
7210 NewOps.drop_back(1 + cast<CallInst>(I)->getNumTotalBundleOperands()), Q);
7212 return llvm::simplifyFreezeInst(NewOps[0], Q);
7216 return simplifyCastInst(I->getOpcode(), NewOps[0], I->getType(), Q,
7222 return simplifyLoadInst(cast<LoadInst>(I), NewOps[0], Q);