[PATCH] D146347: [InstCombine] Improve transforms for `(mul X, Y)` -> `(shl X, log2(Y)`

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 18 14:01:16 PDT 2023


goldstein.w.n marked an inline comment as done.
goldstein.w.n added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:489
+    return replaceInstUsesWith(I, Builder.CreateShl(Op0, Res, I.getName()));
+  }
+
----------------
nikic wrote:
> We should preserve the nuw flag here: https://alive2.llvm.org/ce/z/YkwtoD
> 
> We can't preserve nsw due to the INT_MIN edge case: https://alive2.llvm.org/ce/z/HTaC3b
> We should preserve the nuw flag here: https://alive2.llvm.org/ce/z/YkwtoD
> 
> We can't preserve nsw due to the INT_MIN edge case: https://alive2.llvm.org/ce/z/HTaC3b

Also added test this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146347



More information about the llvm-commits mailing list