[PATCH] D157187: [InstCombine] Propagate the nuw/nsw for instruction neg-sub

Allen zhong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 6 23:25:16 PDT 2023


Allen marked an inline comment as done.
Allen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2069
+        if (I.hasNoSignedWrap() && Op1Inst->hasNoSignedWrap())
+          InstOp1->setHasNoSignedWrap();
+      }
----------------
goldstein.w.n wrote:
> I don't think its okay to modify NegOp1 inplace like this. the flag propagation works in the context of the transform at hand but might not be applicable to all users.
> 
> Also this desperately needs some comments.
Apply your comment, thanks. Also add a new test src_neg_sub_both_nsw_other_use for the new checking **Op1->hasOneUse()**


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157187/new/

https://reviews.llvm.org/D157187



More information about the llvm-commits mailing list