[llvm] [Reassociate] Preserve NSW flags after expr tree rewriting (PR #93105)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 10:30:38 PDT 2024
================
@@ -648,6 +651,9 @@ static bool LinearizeExprTree(Instruction *I,
// Ensure the leaf is only output once.
It->second = 0;
Ops.push_back(std::make_pair(V, Weight));
+ if (Opcode == Instruction::Add && Flags.AllKnownNonNegative) {
----------------
akshayrdeodhar wrote:
That makes sense, just that there could be a case where `Flags.AllKnownNonNegative` would be true even if one of the operands is actually negative. (Just because HasNSW is false.
Perhaps a comment explaining that `Flags.AllKnownNonNegative` cannot be used independent of `Flags.HasNSW`
https://github.com/llvm/llvm-project/pull/93105
More information about the llvm-commits
mailing list