summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-12-23 23:31:49 +0000
committerAndrew Trick <atrick@apple.com>2013-12-23 23:31:49 +0000
commit0ba77a074093ed29543803031180b34e10f44abd (patch)
tree82963ed595bcf497a7e251ec2d0364379a41282d /llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
parentb275d7f8f350b089d464ac78936ecd51bf590f2c (diff)
downloadbcm5719-llvm-0ba77a074093ed29543803031180b34e10f44abd.tar.gz
bcm5719-llvm-0ba77a074093ed29543803031180b34e10f44abd.zip
Add support to indvars for optimizing sadd.with.overflow.
Split sadd.with.overflow into add + sadd.with.overflow to allow analysis and optimization. This should ideally be done after InstCombine, which can perform code motion (eventually indvars should run after all canonical instcombines). We want ISEL to recombine the add and the check, at least on x86. This is currently under an option for reducing live induction variables: -liv-reduce. The next step is reducing liveness of IVs that are live out of the overflow check paths. Once the related optimizations are fully developed, reviewed and tested, I do expect this to become default. llvm-svn: 197926
Diffstat (limited to 'llvm/lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 235aaaa6f80..c291f68bd63 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -63,6 +63,9 @@ static cl::opt<bool> VerifyIndvars(
"verify-indvars", cl::Hidden,
cl::desc("Verify the ScalarEvolution result after running indvars"));
+static cl::opt<bool> ReduceLiveIVs("liv-reduce", cl::Hidden,
+ cl::desc("Reduce live induction variables."));
+
namespace {
class IndVarSimplify : public LoopPass {
LoopInfo *LI;
@@ -643,8 +646,11 @@ namespace {
WideIVInfo WI;
WideIVVisitor(PHINode *NarrowIV, ScalarEvolution *SCEV,
- const DataLayout *TData) :
- SE(SCEV), TD(TData) { WI.NarrowIV = NarrowIV; }
+ const DataLayout *TData, const DominatorTree *DTree):
+ SE(SCEV), TD(TData) {
+ DT = DTree;
+ WI.NarrowIV = NarrowIV;
+ }
// Implement the interface used by simplifyUsersOfIV.
virtual void visitCast(CastInst *Cast);
@@ -1114,7 +1120,9 @@ void IndVarSimplify::SimplifyAndExtend(Loop *L,
PHINode *CurrIV = LoopPhis.pop_back_val();
// Information about sign/zero extensions of CurrIV.
- WideIVVisitor WIV(CurrIV, SE, TD);
+ WideIVVisitor WIV(CurrIV, SE, TD, DT);
+ if (ReduceLiveIVs)
+ WIV.setSplitOverflowIntrinsics();
Changed |= simplifyUsersOfIV(CurrIV, SE, &LPM, DeadInsts, &WIV);
OpenPOWER on IntegriCloud