[LSR] canonicalize Prod*(1<<C) to Prod<<C
authorJingyue Wu <jingyue@google.com>
Wed, 24 Jun 2015 19:28:40 +0000 (19:28 +0000)
committerJingyue Wu <jingyue@google.com>
Wed, 24 Jun 2015 19:28:40 +0000 (19:28 +0000)
commit5d59315f13ff8bb19eda0c378964b95676680f0f
tree52a0a9d13fc8772e79413ec93fbd4df04ba245c4
parent1171dada028c4a79953b9ecc6a726b1f8abd78d3
[LSR] canonicalize Prod*(1<<C) to Prod<<C

Summary:
Because LSR happens at a late stage where mul of a power of 2 is
typically canonicalized to shl, this canonicalization emits code that
can be better CSE'ed.

Test Plan:
Transforms/LoopStrengthReduce/shl.ll shows how this change makes GVN more
powerful. Fixes some existing tests due to this change.

Reviewers: sanjoy, majnemer, atrick

Reviewed By: majnemer, atrick

Subscribers: majnemer, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240573 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolutionExpander.cpp
test/Transforms/LoopIdiom/basic.ll
test/Transforms/LoopReroll/nonconst_lb.ll
test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
test/Transforms/LoopStrengthReduce/shl.ll [new file with mode: 0644]