[PATCH] D132412: [InstCombine] reassociate/factor add+mul with common operand

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 17:04:59 PDT 2022


hiraditya added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1422
+                        m_OneUse(m_c_Add(m_Deferred(X), m_Value(Z)))))) {
+    // (X * Y) + (X + Z) --> ((Y + 1) * X) + Z
+    Value *IncY = Builder.CreateAdd(Y, ConstantInt::get(I.getType(), 1));
----------------
Can this cause a regression when Y  is a power of two?
Some other optimization would rewrite `x*y` as `y << n (when n == lg(y) at compile time)`?


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

https://reviews.llvm.org/D132412



More information about the llvm-commits mailing list