[llvm] [ConstraintElim] Add NSW to ADD if one op is nneg and other npos. (PR #221487)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 04:11:54 PDT 2026
================
@@ -1356,6 +1370,21 @@ static bool tryToStrengthenFlags(Instruction *I, ConstraintInfo &Info,
I->setHasNoUnsignedWrap();
return true;
}
+ case Instruction::Add: {
+ // Op0 + Op1 does not wrap signed, if one operand is non-negative and the
----------------
fhahn wrote:
Yep, we can effectively re-use the Mul/Shl range logic for those cases.
We still miss some cases (I think we the boundary we check is signed min, which cannot be decomposed, but overall we get a number of additional flags for cheaper (fewer queries) https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1215
https://github.com/llvm/llvm-project/pull/221487
More information about the llvm-commits
mailing list