[PATCH] D125198: [InstCombine] ((A + B) + C) + A --> (A << 1) + (B + C)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 01:11:48 PDT 2022


RKSimon added a comment.

What's the motiviation for this patch? I notice we already get the shift+add pattern: https://clang.godbolt.org/z/58c6e9jbj



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1356
+        Value *ADD = RHS == A ? Builder.CreateAdd(B, C, "reass.add")
+                              : Builder.CreateAdd(A, C, "reass.add");
+        return BinaryOperator::CreateAdd(SHL, ADD);
----------------
Slightly tidier to minimise CreateAdd calls?

Value *ADD = Builder.CreateAdd(RHS == A ? B : A, C, "reass.add")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125198



More information about the llvm-commits mailing list