Add DAG combine for shl + add of constants.
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 11 Sep 2014 17:34:19 +0000 (17:34 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 11 Sep 2014 17:34:19 +0000 (17:34 +0000)
commit31b1bdbd959dcae3384f1306107510dc018b403d
treeb0e205107f3f5c1bb5465d846c230914acb24d2f
parent761ca139910edabca9320120b1df841001dcd504
Add DAG combine for shl + add of constants.

Do
 (shl (add x, c1), c2) -> (add (shl x, c2), c1 << c2)

This is already done for multiplies, but since multiplies
by powers of two are turned into shifts, we also need
to handle it here.

This might want checks for isLegalAddImmediate to avoid
transforming an add of a legal immediate with one that isn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217610 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/AArch64/arm64-shifted-sext.ll
test/CodeGen/R600/shl_add_constant.ll [new file with mode: 0644]
test/CodeGen/R600/shl_add_ptr.ll
test/CodeGen/R600/trunc.ll
test/CodeGen/X86/add_shl_constant.ll [new file with mode: 0644]