[llvm] [Reassociate] Preserve `nuw` and `nsw` on `mul` chains (PR #97040)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 10:10:34 PDT 2024
================
@@ -539,6 +539,16 @@ static bool LinearizeExprTree(Instruction *I,
Ops.push_back(std::make_pair(V, Weight));
if (Opcode == Instruction::Add && Flags.AllKnownNonNegative && Flags.HasNSW)
Flags.AllKnownNonNegative &= isKnownNonNegative(V, SimplifyQuery(DL));
+ else if (Opcode == Instruction::Mul) {
+ // To preserve NUW we need all inputs non-zero.
+ // To preserve NSW we need all inputs strictly positive.
----------------
akshayrdeodhar wrote:
Similar to AllKnownNonNegative- its possible for AllKnownNonZero to be `true` in a case where an operand is 0, but `HasNUW` and `HasNSW` are false. Perhaps update the comment on line 71?
nbd, upto you.
https://github.com/llvm/llvm-project/pull/97040
More information about the llvm-commits
mailing list