[InstCombine] (A + B) + B --> A + (B << 1)
authorSanjay Patel <spatel@rotateright.com>
Fri, 22 May 2020 15:37:58 +0000 (11:37 -0400)
committerSanjay Patel <spatel@rotateright.com>
Fri, 22 May 2020 15:46:59 +0000 (11:46 -0400)
commit2f7c24fe303f09308f1032515379f0abf20c5f90
treef1090283e492d68c34dbd98f09e60d6f0f4e477c
parentb603794061f651695b155a0456a701d0ad82e8f4
[InstCombine] (A + B) + B --> A + (B << 1)

This eliminates a use of 'B', so it can enable follow-on transforms
as well as improve analysis/codegen.

The PhaseOrdering test was added for D61726, and that shows
the limits of instcombine vs. real reassociation. We would
need to run some form of CSE to collapse that further.

The intermediate variable naming here is intentional because
there's a test at llvm/test/Bitcode/value-with-long-name.ll
that would break with the usual nameless value. I'm not sure
how to improve that test to be more robust.

The naming may also be helpful to debug regressions if this
change exposes weaknesses in the reassociation pass for example.
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/add.ll
llvm/test/Transforms/PGOProfile/chr.ll
llvm/test/Transforms/PhaseOrdering/reassociate-after-unroll.ll