[PATCH] D156811: [InstCombine] Fold `select` of `srem` and conditional add

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 09:58:29 PDT 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2604
+  // %cnd = icmp slt i32 %rem, 0
+  // %add = add nsw i32 %rem, %n
+  // %sel = select i1 %cnd, i32 %add, i32 %rem
----------------
antoniofrighetto wrote:
> goldstein.w.n wrote:
> > Can you remove the NSW from the comment / all the alive2 links. It makes it seem like the `nsw` is necessary for correctness.
> Dropped, thanks.
Use `InstCombiner::isSignBitCheck` so you can handle the case where the condition is inverted and the add and srem operands are swapped.


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

https://reviews.llvm.org/D156811



More information about the llvm-commits mailing list