[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)
commit6f72aed3ecda230814e1701d96f235d9a04b84af
treefc22625fadcab9e965646a900c63c4f02fd3d664
parentc1ffd69c3424dc8cdb3a24f18cd3e4901ce918aa
[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

llvm-svn: 240573
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/test/Transforms/LoopIdiom/basic.ll
llvm/test/Transforms/LoopReroll/nonconst_lb.ll
llvm/test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
llvm/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
llvm/test/Transforms/LoopStrengthReduce/shl.ll [new file with mode: 0644]