[SLSR] handle candidate form &B[i * S]
authorJingyue Wu <jingyue@google.com>
Thu, 26 Mar 2015 16:49:24 +0000 (16:49 +0000)
committerJingyue Wu <jingyue@google.com>
Thu, 26 Mar 2015 16:49:24 +0000 (16:49 +0000)
commit439d17ca9f66b8c12563628fc4b213608b1967d5
tree4baa948cf26dcc9f1b50cb5c2830db086e0627c1
parent54b6c4c7095e1d73e3d746564163617fcc6b7fd2
[SLSR] handle candidate form &B[i * S]

Summary:
This patch enhances SLSR to handle another candidate form &B[i * S]. If
we found two candidates

S1: X = &B[i * S]
S2: Y = &B[i' * S]

and S1 dominates S2, we can replace S2 with

Y = &X[(i' - i) * S]

Test Plan:
slsr-gep.ll
X86/no-slsr.ll: verify that we do not run SLSR on GEPs that already fit into
an addressing mode

Reviewers: eliben, atrick, meheff, hfinkel

Reviewed By: hfinkel

Subscribers: sanjoy, llvm-commits

Differential Revision: http://reviews.llvm.org/D7459

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233286 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
test/Transforms/StraightLineStrengthReduce/X86/lit.local.cfg [new file with mode: 0644]
test/Transforms/StraightLineStrengthReduce/X86/no-slsr.ll [new file with mode: 0644]
test/Transforms/StraightLineStrengthReduce/slsr-gep.ll [new file with mode: 0644]
test/Transforms/StraightLineStrengthReduce/slsr-mul.ll [new file with mode: 0644]
test/Transforms/StraightLineStrengthReduce/slsr.ll [deleted file]