Simplify handling of shifts to be the same as we do for adds. Add support
authorChris Lattner <sabre@nondot.org>
Sat, 13 Nov 2004 19:50:12 +0000 (19:50 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 13 Nov 2004 19:50:12 +0000 (19:50 +0000)
commit50af16a97b3983c224a48ae4369d7e9facf8174e
tree65c919b6cf46be906fc0f562734b82995a9a5497
parent706759e8c99ee78bec9fc90c9ac7efd668b284d3
Simplify handling of shifts to be the same as we do for adds.  Add support
for (X * C1) + (X * C2) (where * can be mul or shl), allowing us to fold:

   Y+Y+Y+Y+Y+Y+Y+Y

into
         %tmp.8 = shl long %Y, ubyte 3           ; <long> [#uses=1]

instead of

        %tmp.4 = shl long %Y, ubyte 2           ; <long> [#uses=1]
        %tmp.12 = shl long %Y, ubyte 2          ; <long> [#uses=1]
        %tmp.8 = add long %tmp.4, %tmp.12               ; <long> [#uses=1]

This implements add.ll:test25

Also add support for (X*C1)-(X*C2) -> X*(C1-C2), implementing sub.ll:test18

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17704 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/InstructionCombining.cpp