[PATCH] D148609: [InstCombine] Fix buggy `(mul X, Y)` -> `(shl X, Log2(Y))` transform PR62175

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 00:58:10 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:189
 static Value *takeLog2(IRBuilderBase &Builder, Value *Op, unsigned Depth,
-                       bool DoFold);
+                       bool RequireNoOverflow, bool DoFold);
 
----------------
Replace RequireNoOverflow with an AssumeNonZero flag. This is what justifies it for division.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1227
+      if (!Usable && match(X, m_SpecificInt(1)))
+        Usable = true;
+    }
----------------
Don't we always infer nuw for shl of one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148609



More information about the llvm-commits mailing list