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 <algorithm>
28using namespace llvm;
29
30char IVUsers::ID = 0;
31static RegisterPass<IVUsers>
32X("iv-users", "Induction Variable Users", false, true);
33
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
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 ---
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 <algorithm>
28using namespace llvm;
29
30char IVUsers::ID = 0;
31static RegisterPass<IVUsers>
32X("iv-users", "Induction Variable Users", false, true);
33
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
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 ---