aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/IVUsers.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2009-11-19 02:05:44 +0000
committerJim Grosbach <grosbach@apple.com>2009-11-19 02:05:44 +0000
commit97200e4dd4576d2a07547e07f8118cd01b63f2e9 (patch)
tree23087dc840e9d6175b22f75e541663ce44472889 /lib/Analysis/IVUsers.cpp
parentd0b552cc5680ae245258598586115d05291b7b19 (diff)
downloadexternal_llvm-97200e4dd4576d2a07547e07f8118cd01b63f2e9.zip
external_llvm-97200e4dd4576d2a07547e07f8118cd01b63f2e9.tar.gz
external_llvm-97200e4dd4576d2a07547e07f8118cd01b63f2e9.tar.bz2
Teach IVUsers to keep things simpler and track loop-invariant strides only
for uses inside the loop. This works better with LSR. Disabled behind -simplify-iv-users while benchmarking. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IVUsers.cpp')
-rw-r--r--lib/Analysis/IVUsers.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp
index cf52320..efe40e4 100644
--- a/lib/Analysis/IVUsers.cpp
+++ b/lib/Analysis/IVUsers.cpp
@@ -24,6 +24,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/CommandLine.h"
#include <algorithm>
using namespace llvm;
@@ -31,6 +32,10 @@ char IVUsers::ID = 0;
static RegisterPass<IVUsers>
X("iv-users", "Induction Variable Users", false, true);
+static cl::opt<bool>
+SimplifyIVUsers("simplify-iv-users", cl::Hidden, cl::init(false),
+ cl::desc("Restrict IV Users to loop-invariant strides"));
+
Pass *llvm::createIVUsersPass() {
return new IVUsers();
}
@@ -208,6 +213,11 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I) {
if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT))
return false; // Non-reducible symbolic expression, bail out.
+ // Keep things simple. Don't touch loop-variant strides.
+ if (SimplifyIVUsers && !Stride->isLoopInvariant(L)
+ && L->contains(I->getParent()))
+ return false;
+
SmallPtrSet<Instruction *, 4> UniqueUsers;
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
UI != E; ++UI) {