Enable exitValue rewrite only when the cost of expansion is low.
authorWei Mi <wmi@google.com>
Thu, 28 May 2015 21:49:07 +0000 (21:49 +0000)
committerWei Mi <wmi@google.com>
Thu, 28 May 2015 21:49:07 +0000 (21:49 +0000)
commit61897e856475ed084145679d8182c6703e2a1bf1
tree5f1d8df35545809e685ab889b429344372f00f69
parent9886da621d5fb610891211994a15bf4e412c912a
Enable exitValue rewrite only when the cost of expansion is low.

The patch evaluates the expansion cost of exitValue in indVarSimplify pass, and only does the rewriting when the expansion cost is low or loop can be deleted with the rewriting. It provides an option "-replexitval=" to control the default aggressiveness of the exitvalue rewriting. It also fixes some missing cases in SCEVExpander::isHighCostExpansionHelper to enhance the evaluation of SCEV expansion cost.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238507 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolutionExpander.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
test/Transforms/IndVarSimplify/exit_value_test2.ll [new file with mode: 0644]
test/Transforms/IndVarSimplify/exit_value_test3.ll [new file with mode: 0644]
test/Transforms/IndVarSimplify/lcssa-preservation.ll