[llvm] [ConstraintElim] Unify no-wrap queries. (PR #223537)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 05:46:06 PDT 2026
================
@@ -660,79 +738,58 @@ static Decomposition decompose(Value *V, const ConstraintInfo &Info,
V = Op0;
} else if (match(V, m_SExt(m_Value(Op0)))) {
// Looking through the sext is only valid if the operand is non-negative.
- if (!preconditionHolds(Info, CmpInst::ICMP_SGE, Op0, 0))
+ if (!Info.isKnownNonNegative(Op0))
return V;
V = Op0;
} else if (auto *Trunc = dyn_cast<TruncInst>(V)) {
if (Trunc->getSrcTy()->getScalarSizeInBits() <= 64 &&
- (Trunc->hasNoUnsignedWrap() || Trunc->hasNoSignedWrap())) {
- Value *Src = Trunc->getOperand(0);
- // A trunc nsw only truncates without unsigned wrap if its operand is
- // non-negative.
- if (!Trunc->hasNoUnsignedWrap() &&
- !preconditionHolds(Info, CmpInst::ICMP_SGE, Src, 0))
- return V;
- V = Src;
- }
+ isKnownNoWrap(Trunc, Info, /*Signed=*/false))
+ V = Trunc->getOperand(0);
----------------
fhahn wrote:
Yep, some of the code can be shared, although those changes should be NFC and I'd prefer to keep this as separate cleanup change, so it is easier to verify NFC-ness
https://github.com/llvm/llvm-project/pull/223537
More information about the llvm-commits
mailing list