[PATCH] Simplify n-ary adds by reassociation

Jingyue Wu jingyue at google.com
Thu Apr 9 21:26:30 PDT 2015


Hi atrick, broune, dberlin, hfinkel, meheff, sanjoy,

This transformation reassociates a n-ary add so that the add can partially reuse
existing instructions. For example, this pass can simplify

  void foo(int a, int b) {
    bar(a + b);
    bar((a + 2) + b);
  }

to

  void foo(int a, int b) {
    int t = a + b;
    bar(t);
    bar(t + 2);
  }

saving one add instruction.

Fixes PR22357 (https://llvm.org/bugs/show_bug.cgi?id=22357).

http://reviews.llvm.org/D8950

Files:
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  include/llvm/Transforms/Scalar.h
  lib/Transforms/Scalar/CMakeLists.txt
  lib/Transforms/Scalar/NaryReassociate.cpp
  lib/Transforms/Scalar/Scalar.cpp
  test/Transforms/NaryReassociate/nary-add.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8950.23563.patch
Type: text/x-patch
Size: 13045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150410/7b259701/attachment.bin>


More information about the llvm-commits mailing list