[SCEV] Try to reuse existing value during SCEV expansion
authorWei Mi <wmi@google.com>
Wed, 3 Feb 2016 17:05:12 +0000 (17:05 +0000)
committerWei Mi <wmi@google.com>
Wed, 3 Feb 2016 17:05:12 +0000 (17:05 +0000)
commited133978a0eed72b40f1a86c220445acb24f32f9
treef2c6e1ad7942af2d652c4ba3b28f7e3749d942c6
parent38a36c4f1ca7a0a42ac6524a9f0a5a701f3bc88a
[SCEV] Try to reuse existing value during SCEV expansion

Current SCEV expansion will expand SCEV as a sequence of operations
and doesn't utilize the value already existed. This will introduce
redundent computation which may not be cleaned up throughly by
following optimizations.

This patch introduces an ExprValueMap which is a map from SCEV to the
set of equal values with the same SCEV. When a SCEV is expanded, the
set of values is checked and reused whenever possible before generating
a sequence of operations.

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

llvm-svn: 259662
12 files changed:
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Analysis/ScalarEvolution/scev-expander-existing-value.ll [new file with mode: 0644]
llvm/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll
llvm/test/Transforms/IRCE/decrementing-loop.ll
llvm/test/Transforms/IndVarSimplify/lftr-address-space-pointers.ll
llvm/test/Transforms/IndVarSimplify/pr24783.ll
llvm/test/Transforms/IndVarSimplify/udiv.ll
llvm/test/Transforms/IndVarSimplify/ult-sub-to-eq.ll
llvm/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll