Deleted Added
full compact
IVUsers.cpp (199481) IVUsers.cpp (199511)
1//===- IVUsers.cpp - Induction Variable Users -------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 10 unchanged lines hidden (view full) ---

19#include "llvm/Type.h"
20#include "llvm/DerivedTypes.h"
21#include "llvm/Analysis/Dominators.h"
22#include "llvm/Analysis/LoopPass.h"
23#include "llvm/Analysis/ScalarEvolutionExpressions.h"
24#include "llvm/ADT/STLExtras.h"
25#include "llvm/Support/Debug.h"
26#include "llvm/Support/raw_ostream.h"
1//===- IVUsers.cpp - Induction Variable Users -------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 10 unchanged lines hidden (view full) ---

19#include "llvm/Type.h"
20#include "llvm/DerivedTypes.h"
21#include "llvm/Analysis/Dominators.h"
22#include "llvm/Analysis/LoopPass.h"
23#include "llvm/Analysis/ScalarEvolutionExpressions.h"
24#include "llvm/ADT/STLExtras.h"
25#include "llvm/Support/Debug.h"
26#include "llvm/Support/raw_ostream.h"
27#include "llvm/Support/CommandLine.h"
27#include <algorithm>
28using namespace llvm;
29
30char IVUsers::ID = 0;
31static RegisterPass<IVUsers>
32X("iv-users", "Induction Variable Users", false, true);
33
28#include <algorithm>
29using namespace llvm;
30
31char IVUsers::ID = 0;
32static RegisterPass<IVUsers>
33X("iv-users", "Induction Variable Users", false, true);
34
35static cl::opt<bool>
36SimplifyIVUsers("simplify-iv-users", cl::Hidden, cl::init(false),
37 cl::desc("Restrict IV Users to loop-invariant strides"));
38
34Pass *llvm::createIVUsersPass() {
35 return new IVUsers();
36}
37
38/// containsAddRecFromDifferentLoop - Determine whether expression S involves a
39/// subexpression that is an AddRec from a loop other than L. An outer loop
40/// of L is OK, but not an inner loop nor a disjoint loop.
41static bool containsAddRecFromDifferentLoop(const SCEV *S, Loop *L) {

--- 161 unchanged lines hidden (view full) ---

203 // Get the start and stride for this expression.
204 Loop *UseLoop = LI->getLoopFor(I->getParent());
205 const SCEV *Start = SE->getIntegerSCEV(0, ISE->getType());
206 const SCEV *Stride = Start;
207
208 if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT))
209 return false; // Non-reducible symbolic expression, bail out.
210
39Pass *llvm::createIVUsersPass() {
40 return new IVUsers();
41}
42
43/// containsAddRecFromDifferentLoop - Determine whether expression S involves a
44/// subexpression that is an AddRec from a loop other than L. An outer loop
45/// of L is OK, but not an inner loop nor a disjoint loop.
46static bool containsAddRecFromDifferentLoop(const SCEV *S, Loop *L) {

--- 161 unchanged lines hidden (view full) ---

208 // Get the start and stride for this expression.
209 Loop *UseLoop = LI->getLoopFor(I->getParent());
210 const SCEV *Start = SE->getIntegerSCEV(0, ISE->getType());
211 const SCEV *Stride = Start;
212
213 if (!getSCEVStartAndStride(ISE, L, UseLoop, Start, Stride, SE, DT))
214 return false; // Non-reducible symbolic expression, bail out.
215
216 // Keep things simple. Don't touch loop-variant strides.
217 if (SimplifyIVUsers && !Stride->isLoopInvariant(L)
218 && L->contains(I->getParent()))
219 return false;
220
211 SmallPtrSet<Instruction *, 4> UniqueUsers;
212 for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
213 UI != E; ++UI) {
214 Instruction *User = cast<Instruction>(*UI);
215 if (!UniqueUsers.insert(User))
216 continue;
217
218 // Do not infinitely recurse on PHI nodes.

--- 157 unchanged lines hidden ---
221 SmallPtrSet<Instruction *, 4> UniqueUsers;
222 for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
223 UI != E; ++UI) {
224 Instruction *User = cast<Instruction>(*UI);
225 if (!UniqueUsers.insert(User))
226 continue;
227
228 // Do not infinitely recurse on PHI nodes.

--- 157 unchanged lines hidden ---