[llvm-commits] [llvm] r139517 - in /llvm/trunk: lib/Transforms/Scalar/ test/Transforms/IndVarSimplify/ test/Transforms/LoopUnroll/
Andrew Trick
atrick at apple.com
Mon Sep 12 11:28:44 PDT 2011
Author: atrick
Date: Mon Sep 12 13:28:44 2011
New Revision: 139517
URL: http://llvm.org/viewvc/llvm-project?rev=139517&view=rev
Log:
Rename -disable-iv-rewrite to -enable-iv-rewrite=false in preparation for default change.
Modified:
llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/trunk/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll
llvm/trunk/test/Transforms/IndVarSimplify/ada-loops.ll
llvm/trunk/test/Transforms/IndVarSimplify/elim-extend.ll
llvm/trunk/test/Transforms/IndVarSimplify/iv-fold.ll
llvm/trunk/test/Transforms/IndVarSimplify/iv-zext.ll
llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll
llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
llvm/trunk/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
llvm/trunk/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll
llvm/trunk/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll
Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Sep 12 13:28:44 2011
@@ -11,17 +11,6 @@
// computations derived from them) into simpler forms suitable for subsequent
// analysis and transformation.
//
-// Additionally, unless -disable-iv-rewrite is on, this transformation makes the
-// following changes to each loop with an identifiable induction variable:
-// 1. All loops are transformed to have a SINGLE canonical induction variable
-// which starts at zero and steps by one.
-// 2. The canonical induction variable is guaranteed to be the first PHI node
-// in the loop header block.
-// 3. The canonical induction variable is guaranteed to be in a wide enough
-// type so that IV expressions need not be (directly) zero-extended or
-// sign-extended.
-// 4. Any pointer arithmetic recurrences are raised to use array subscripts.
-//
// If the trip count of a loop is computable, this pass also makes the following
// changes:
// 1. The exit condition for the loop is canonicalized to compare the
@@ -33,9 +22,6 @@
// purpose of the loop is to compute the exit value of some derived
// expression, this transformation will make the loop dead.
//
-// This transformation should be followed by strength reduction after all of the
-// desired loop transformations have been performed.
-//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "indvars"
@@ -73,9 +59,9 @@
STATISTIC(NumElimIV , "Number of congruent IVs eliminated");
namespace llvm {
- cl::opt<bool> DisableIVRewrite(
- "disable-iv-rewrite", cl::Hidden,
- cl::desc("Disable canonical induction variable rewriting"));
+ cl::opt<bool> EnableIVRewrite(
+ "enable-iv-rewrite", cl::Hidden, cl::init(true),
+ cl::desc("Enable canonical induction variable rewriting"));
// Trip count verification can be enabled by default under NDEBUG if we
// implement a strong expression equivalence checker in SCEV. Until then, we
@@ -85,12 +71,6 @@
cl::desc("Verify the ScalarEvolution result after running indvars"));
}
-// Temporary flag for use with -disable-iv-rewrite to force a canonical IV for
-// LFTR purposes.
-static cl::opt<bool> ForceLFTR(
- "force-lftr", cl::Hidden,
- cl::desc("Enable forced linear function test replacement"));
-
namespace {
class IndVarSimplify : public LoopPass {
IVUsers *IU;
@@ -117,12 +97,12 @@
AU.addRequired<ScalarEvolution>();
AU.addRequiredID(LoopSimplifyID);
AU.addRequiredID(LCSSAID);
- if (!DisableIVRewrite)
+ if (EnableIVRewrite)
AU.addRequired<IVUsers>();
AU.addPreserved<ScalarEvolution>();
AU.addPreservedID(LoopSimplifyID);
AU.addPreservedID(LCSSAID);
- if (!DisableIVRewrite)
+ if (EnableIVRewrite)
AU.addPreserved<IVUsers>();
AU.setPreservesCFG();
}
@@ -618,7 +598,7 @@
//===----------------------------------------------------------------------===//
// Rewrite IV users based on a canonical IV.
-// To be replaced by -disable-iv-rewrite.
+// Only for use with -enable-iv-rewrite.
//===----------------------------------------------------------------------===//
/// FIXME: It is an extremely bad idea to indvar substitute anything more
@@ -1333,7 +1313,7 @@
}
}
- if (!DisableIVRewrite || ForceLFTR)
+ if (EnableIVRewrite)
return false;
// Recurse past add expressions, which commonly occur in the
@@ -1610,10 +1590,9 @@
assert(canExpandBackedgeTakenCount(L, SE) && "precondition");
BranchInst *BI = cast<BranchInst>(L->getExitingBlock()->getTerminator());
- // In DisableIVRewrite mode, IndVar is not necessarily a canonical IV. In this
- // mode, LFTR can ignore IV overflow and truncate to the width of
+ // LFTR can ignore IV overflow and truncate to the width of
// BECount. This avoids materializing the add(zext(add)) expression.
- Type *CntTy = DisableIVRewrite ?
+ Type *CntTy = !EnableIVRewrite ?
BackedgeTakenCount->getType() : IndVar->getType();
const SCEV *IVLimit = BackedgeTakenCount;
@@ -1663,7 +1642,7 @@
const SCEV *IVInit = AR->getStart();
// For pointer types, sign extend BECount in order to materialize a GEP.
- // Note that for DisableIVRewrite, we never run SCEVExpander on a
+ // Note that for without EnableIVRewrite, we never run SCEVExpander on a
// pointer type, because we must preserve the existing GEPs. Instead we
// directly generate a GEP later.
if (IVInit->getType()->isPointerTy()) {
@@ -1841,7 +1820,7 @@
if (!L->isLoopSimplifyForm())
return false;
- if (!DisableIVRewrite)
+ if (EnableIVRewrite)
IU = &getAnalysis<IVUsers>();
LI = &getAnalysis<LoopInfo>();
SE = &getAnalysis<ScalarEvolution>();
@@ -1866,7 +1845,7 @@
// attempt to avoid evaluating SCEVs for sign/zero extend operations until
// other expressions involving loop IVs have been evaluated. This helps SCEV
// set no-wrap flags before normalizing sign/zero extension.
- if (DisableIVRewrite) {
+ if (!EnableIVRewrite) {
Rewriter.disableCanonicalMode();
SimplifyAndExtend(L, Rewriter, LPM);
}
@@ -1881,26 +1860,25 @@
RewriteLoopExitValues(L, Rewriter);
// Eliminate redundant IV users.
- if (!DisableIVRewrite)
+ if (EnableIVRewrite)
Changed |= simplifyIVUsers(IU, SE, &LPM, DeadInsts);
// Eliminate redundant IV cycles.
- if (DisableIVRewrite)
+ if (!EnableIVRewrite)
SimplifyCongruentIVs(L);
// Compute the type of the largest recurrence expression, and decide whether
// a canonical induction variable should be inserted.
Type *LargestType = 0;
bool NeedCannIV = false;
- bool ReuseIVForExit = DisableIVRewrite && !ForceLFTR;
bool ExpandBECount = canExpandBackedgeTakenCount(L, SE);
- if (ExpandBECount && !ReuseIVForExit) {
+ if (EnableIVRewrite && ExpandBECount) {
// If we have a known trip count and a single exit block, we'll be
// rewriting the loop exit test condition below, which requires a
// canonical induction variable.
NeedCannIV = true;
Type *Ty = BackedgeTakenCount->getType();
- if (DisableIVRewrite) {
+ if (!EnableIVRewrite) {
// In this mode, SimplifyIVUsers may have already widened the IV used by
// the backedge test and inserted a Trunc on the compare's operand. Get
// the wider type to avoid creating a redundant narrow IV only used by the
@@ -1912,7 +1890,7 @@
SE->getTypeSizeInBits(LargestType))
LargestType = SE->getEffectiveSCEVType(Ty);
}
- if (!DisableIVRewrite) {
+ if (EnableIVRewrite) {
for (IVUsers::const_iterator I = IU->begin(), E = IU->end(); I != E; ++I) {
NeedCannIV = true;
Type *Ty =
@@ -1957,7 +1935,7 @@
OldCannIV->insertBefore(L->getHeader()->getFirstInsertionPt());
}
}
- else if (ExpandBECount && ReuseIVForExit && needsLFTR(L, DT)) {
+ else if (!EnableIVRewrite && ExpandBECount && needsLFTR(L, DT)) {
IndVar = FindLoopCounter(L, BackedgeTakenCount, SE, DT, TD);
}
// If we have a trip count expression, rewrite the loop's exit condition
@@ -1978,7 +1956,7 @@
LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, Rewriter);
}
// Rewrite IV-derived expressions.
- if (!DisableIVRewrite)
+ if (EnableIVRewrite)
RewriteIVExpressions(L, Rewriter);
// Clear the rewriter cache, because values that are in the rewriter's cache
@@ -2015,7 +1993,7 @@
// Verify that LFTR, and any other change have not interfered with SCEV's
// ability to compute trip count.
#ifndef NDEBUG
- if (DisableIVRewrite && VerifyIndvars &&
+ if (!EnableIVRewrite && VerifyIndvars &&
!isa<SCEVCouldNotCompute>(BackedgeTakenCount)) {
SE->forgetLoop(L);
const SCEV *NewBECount = SE->getBackedgeTakenCount(L);
Modified: llvm/trunk/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
; Test WidenIV::GetExtendedOperandRecurrence.
; add219 should be extended to i64 because it is nsw, even though its
; sext cannot be hoisted outside the loop.
Modified: llvm/trunk/test/Transforms/IndVarSimplify/ada-loops.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/ada-loops.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/ada-loops.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/ada-loops.ll Mon Sep 12 13:28:44 2011
@@ -1,5 +1,5 @@
; RUN: opt < %s -indvars -S | FileCheck %s
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
;
; PR1301
Modified: llvm/trunk/test/Transforms/IndVarSimplify/elim-extend.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/elim-extend.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/elim-extend.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/elim-extend.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
Modified: llvm/trunk/test/Transforms/IndVarSimplify/iv-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/iv-fold.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/iv-fold.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/iv-fold.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n:32:64"
Modified: llvm/trunk/test/Transforms/IndVarSimplify/iv-zext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/iv-zext.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/iv-zext.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/iv-zext.ll Mon Sep 12 13:28:44 2011
@@ -1,5 +1,5 @@
; RUN: opt < %s -indvars -S | FileCheck %s
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
; CHECK-NOT: and
; CHECK-NOT: zext
Modified: llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/lftr-reuse.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
;
; Make sure that indvars can perform LFTR without a canonical IV.
Modified: llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/no-iv-rewrite.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
;
; Make sure that indvars isn't inserting canonical IVs.
; This is kinda hard to do until linear function test replacement is removed.
Modified: llvm/trunk/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll Mon Sep 12 13:28:44 2011
@@ -1,5 +1,5 @@
; RUN: opt < %s -indvars -S | FileCheck %s
-; RUN: opt < %s -indvars -disable-iv-rewrite -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s
; Indvars should insert a 64-bit induction variable to eliminate the
; sext for the addressing, however it shouldn't eliminate the sext
Modified: llvm/trunk/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll Mon Sep 12 13:28:44 2011
@@ -1,5 +1,5 @@
; RUN: opt < %s -indvars -instcombine -S | FileCheck %s
-; RUN: opt < %s -indvars -disable-iv-rewrite -instcombine -S | FileCheck %s
+; RUN: opt < %s -indvars -enable-iv-rewrite=false -instcombine -S | FileCheck %s
;
; Test that -indvars can reduce variable stride IVs. If it can reduce variable
; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
Modified: llvm/trunk/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll?rev=139517&r1=139516&r2=139517&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/2011-08-09-IVSimplify.ll Mon Sep 12 13:28:44 2011
@@ -1,4 +1,4 @@
-; RUN: opt -S < %s -loop-unroll -unroll-count=4 -disable-iv-rewrite | FileCheck %s
+; RUN: opt -S < %s -loop-unroll -unroll-count=4 -enable-iv-rewrite=false | FileCheck %s
;
; Test induction variable simplify after loop unrolling. It should
; expose nice opportunities for GVN.
More information about the llvm-commits
mailing list