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

chenglin.bi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 09:03:52 PDT 2022


bcl5980 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1423
+    Value *IncY = Builder.CreateAdd(Y, ConstantInt::get(I.getType(), 1));
+    return BinaryOperator::CreateMul(IncY, X);
+  }
----------------
spatel wrote:
> Allen wrote:
> > should we need consider the flag of NUW and NSW ?
> I only found one case so far where we can partially propagate nuw:
> https://alive2.llvm.org/ce/z/aGSyrK
> Everything else seems to be illegal. Propagating the flag would be another reason to code this match explicitly rather than trying to make it work through tryFactorization().
If we don't move it to tryFactorization, do we  need to add the similar pattern x*y - x --> (x-1) * y ?


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

https://reviews.llvm.org/D132412



More information about the llvm-commits mailing list