[PATCH] D154289: [Reassociate] Keep flags for more unchanged operations

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 1 13:58:16 PDT 2023


dmgreen created this revision.
dmgreen added reviewers: nikic, spatel.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
dmgreen requested review of this revision.
Herald added a project: LLVM.

Reassociation destroys nsw/nuw flags from BinOps that are changed. If the expression in at the end of a tree that was altered, but didn't change itself the flags do not need to be removed though. For example, if %a, %b and %c are reassociated in

  %x = add nsw i32 %a, %c
  %y = add nsw i32 %x, %b
  %z = add nsw i32 %y, %d

The value of %y and so `add %y %d` remains the same, and %z needn't drop the nsw flags.
https://alive2.llvm.org/ce/z/_juAiV


https://reviews.llvm.org/D154289

Files:
  llvm/lib/Transforms/Scalar/Reassociate.cpp
  llvm/test/Transforms/Reassociate/cse-pairs.ll
  llvm/test/Transforms/Reassociate/local-cse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154289.536545.patch
Type: text/x-patch
Size: 6885 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230701/4da955c5/attachment.bin>


More information about the llvm-commits mailing list