blob: 617c08695b7bca79b6f94995ab0185e1888a2961 [file] [log] [blame]
Chris Lattnerd213f0f2001-06-20 19:27:11 +00001//===- InductionVars.cpp - Induction Variable Cannonicalization code --------=//
2//
3// This file implements induction variable cannonicalization of loops.
4//
5// Specifically, after this executes, the following is true:
Chris Lattner364b1472001-06-22 02:24:38 +00006// - There is a single induction variable for each loop (at least loops that
7// used to contain at least one induction variable)
Chris Lattner3b34c592001-06-27 23:36:09 +00008// * This induction variable starts at 0 and steps by 1 per iteration
9// * This induction variable is represented by the first PHI node in the
Chris Lattner364b1472001-06-22 02:24:38 +000010// Header block, allowing it to be found easily.
Chris Lattnerd213f0f2001-06-20 19:27:11 +000011// - All other preexisting induction variables are adjusted to operate in
12// terms of this primary induction variable
Chris Lattnerd473a0a2001-06-25 07:32:19 +000013// - Induction variables with a step size of 0 have been eliminated.
Chris Lattnerd213f0f2001-06-20 19:27:11 +000014//
Chris Lattner364b1472001-06-22 02:24:38 +000015// This code assumes the following is true to perform its full job:
16// - The CFG has been simplified to not have multiple entrances into an
17// interval header. Interval headers should only have two predecessors,
18// one from inside of the loop and one from outside of the loop.
19//
Chris Lattnerd213f0f2001-06-20 19:27:11 +000020//===----------------------------------------------------------------------===//
21
Chris Lattner59b6b8e2002-01-21 23:17:48 +000022#include "llvm/Transforms/Scalar/InductionVars.h"
Chris Lattnere9bb2df2001-12-03 22:26:30 +000023#include "llvm/ConstantVals.h"
Chris Lattnerc9f39b22001-06-24 04:05:45 +000024#include "llvm/Analysis/IntervalPartition.h"
Chris Lattnerd213f0f2001-06-20 19:27:11 +000025#include "llvm/Assembly/Writer.h"
Chris Lattnerd473a0a2001-06-25 07:32:19 +000026#include "llvm/SymbolTable.h"
Chris Lattner7061dc52001-12-03 18:02:31 +000027#include "llvm/iPHINode.h"
Chris Lattner793c6b82002-01-31 00:45:11 +000028#include "llvm/Method.h"
Chris Lattner221d6882002-02-12 21:07:25 +000029#include "llvm/BasicBlock.h"
Chris Lattner455889a2002-02-12 22:39:50 +000030#include "llvm/InstrTypes.h"
31#include "llvm/Support/CFG.h"
Chris Lattnercee8f9a2001-11-27 00:03:19 +000032#include "Support/STLExtras.h"
Chris Lattnerc9f39b22001-06-24 04:05:45 +000033#include <algorithm>
Chris Lattner697954c2002-01-20 22:54:45 +000034#include <iostream>
35using std::cerr;
Chris Lattnerd213f0f2001-06-20 19:27:11 +000036
Chris Lattner364b1472001-06-22 02:24:38 +000037// isLoopInvariant - Return true if the specified value/basic block source is
38// an interval invariant computation.
39//
40static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +000041 assert(isa<Constant>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
Chris Lattnerd213f0f2001-06-20 19:27:11 +000042
Chris Lattner1d87bcf2001-10-01 20:11:19 +000043 if (!isa<Instruction>(V))
Chris Lattner364b1472001-06-22 02:24:38 +000044 return true; // Constants and arguments are always loop invariant
45
Chris Lattnerb00c5822001-10-02 03:41:24 +000046 BasicBlock *ValueBlock = cast<Instruction>(V)->getParent();
Chris Lattner364b1472001-06-22 02:24:38 +000047 assert(ValueBlock && "Instruction not embedded in basic block!");
48
49 // For now, only consider values from outside of the interval, regardless of
50 // whether the expression could be lifted out of the loop by some LICM.
51 //
52 // TODO: invoke LICM library if we find out it would be useful.
53 //
54 return !Int->contains(ValueBlock);
55}
56
57
58// isLinearInductionVariableH - Return isLIV if the expression V is a linear
59// expression defined in terms of loop invariant computations, and a single
60// instance of the PHI node PN. Return isLIC if the expression V is a loop
61// invariant computation. Return isNLIV if the expression is a negated linear
62// induction variable. Return isOther if it is neither.
63//
64// Currently allowed operators are: ADD, SUB, NEG
65// TODO: This should allow casts!
66//
67enum LIVType { isLIV, isLIC, isNLIV, isOther };
68//
69// neg - Negate the sign of a LIV expression.
70inline LIVType neg(LIVType T) {
71 assert(T == isLIV || T == isNLIV && "Negate Only works on LIV expressions");
72 return T == isLIV ? isNLIV : isLIV;
73}
74//
75static LIVType isLinearInductionVariableH(cfg::Interval *Int, Value *V,
76 PHINode *PN) {
77 if (V == PN) { return isLIV; } // PHI node references are (0+PHI)
78 if (isLoopInvariant(Int, V)) return isLIC;
79
Chris Lattner3b34c592001-06-27 23:36:09 +000080 // loop variant computations must be instructions!
Chris Lattner9636a912001-10-01 16:18:37 +000081 Instruction *I = cast<Instruction>(V);
Chris Lattnera41f50d2001-07-07 19:24:15 +000082 switch (I->getOpcode()) { // Handle each instruction seperately
Chris Lattner364b1472001-06-22 02:24:38 +000083 case Instruction::Add:
84 case Instruction::Sub: {
Chris Lattnerb00c5822001-10-02 03:41:24 +000085 Value *SubV1 = cast<BinaryOperator>(I)->getOperand(0);
86 Value *SubV2 = cast<BinaryOperator>(I)->getOperand(1);
Chris Lattner364b1472001-06-22 02:24:38 +000087 LIVType SubLIVType1 = isLinearInductionVariableH(Int, SubV1, PN);
88 if (SubLIVType1 == isOther) return isOther; // Early bailout
89 LIVType SubLIVType2 = isLinearInductionVariableH(Int, SubV2, PN);
90
91 switch (SubLIVType2) {
92 case isOther: return isOther; // Unknown subexpression type
93 case isLIC: return SubLIVType1; // Constant offset, return type #1
94 case isLIV:
95 case isNLIV:
96 // So now we know that we have a linear induction variable on the RHS of
97 // the ADD or SUB instruction. SubLIVType1 cannot be isOther, so it is
98 // either a Loop Invariant computation, or a LIV type.
99 if (SubLIVType1 == isLIC) {
100 // Loop invariant computation, we know this is a LIV then.
Chris Lattnera41f50d2001-07-07 19:24:15 +0000101 return (I->getOpcode() == Instruction::Add) ?
Chris Lattner364b1472001-06-22 02:24:38 +0000102 SubLIVType2 : neg(SubLIVType2);
103 }
104
105 // If the LHS is also a LIV Expression, we cannot add two LIVs together
Chris Lattnera41f50d2001-07-07 19:24:15 +0000106 if (I->getOpcode() == Instruction::Add) return isOther;
Chris Lattner364b1472001-06-22 02:24:38 +0000107
108 // We can only subtract two LIVs if they are the same type, which yields
109 // a LIC, because the LIVs cancel each other out.
110 return (SubLIVType1 == SubLIVType2) ? isLIC : isOther;
111 }
112 // NOT REACHED
113 }
114
115 default: // Any other instruction is not a LINEAR induction var
116 return isOther;
117 }
118}
119
120// isLinearInductionVariable - Return true if the specified expression is a
121// "linear induction variable", which is an expression involving a single
122// instance of the PHI node and a loop invariant value that is added or
123// subtracted to the PHI node. This is calculated by walking the SSA graph
124//
125static inline bool isLinearInductionVariable(cfg::Interval *Int, Value *V,
126 PHINode *PN) {
127 return isLinearInductionVariableH(Int, V, PN) == isLIV;
128}
129
130
131// isSimpleInductionVar - Return true iff the cannonical induction variable PN
132// has an initializer of the constant value 0, and has a step size of constant
133// 1.
134static inline bool isSimpleInductionVar(PHINode *PN) {
135 assert(PN->getNumIncomingValues() == 2 && "Must have cannonical PHI node!");
136 Value *Initializer = PN->getIncomingValue(0);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000137 if (!isa<Constant>(Initializer)) return false;
Chris Lattner364b1472001-06-22 02:24:38 +0000138
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000139 if (Initializer->getType()->isSigned()) { // Signed constant value...
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000140 if (((ConstantSInt*)Initializer)->getValue() != 0) return false;
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000141 } else if (Initializer->getType()->isUnsigned()) { // Unsigned constant value
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000142 if (((ConstantUInt*)Initializer)->getValue() != 0) return false;
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000143 } else {
144 return false; // Not signed or unsigned? Must be FP type or something
145 }
146
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000147 Value *StepExpr = PN->getIncomingValue(1);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000148 if (!isa<Instruction>(StepExpr) ||
Chris Lattnerb00c5822001-10-02 03:41:24 +0000149 cast<Instruction>(StepExpr)->getOpcode() != Instruction::Add)
Chris Lattner3b34c592001-06-27 23:36:09 +0000150 return false;
151
Chris Lattnerb00c5822001-10-02 03:41:24 +0000152 BinaryOperator *I = cast<BinaryOperator>(StepExpr);
153 assert(isa<PHINode>(I->getOperand(0)) &&
Chris Lattner364b1472001-06-22 02:24:38 +0000154 "PHI node should be first operand of ADD instruction!");
155
156 // Get the right hand side of the ADD node. See if it is a constant 1.
157 Value *StepSize = I->getOperand(1);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000158 if (!isa<Constant>(StepSize)) return false;
Chris Lattner364b1472001-06-22 02:24:38 +0000159
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000160 if (StepSize->getType()->isSigned()) { // Signed constant value...
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000161 if (((ConstantSInt*)StepSize)->getValue() != 1) return false;
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000162 } else if (StepSize->getType()->isUnsigned()) { // Unsigned constant value
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000163 if (((ConstantUInt*)StepSize)->getValue() != 1) return false;
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000164 } else {
165 return false; // Not signed or unsigned? Must be FP type or something
166 }
Chris Lattner364b1472001-06-22 02:24:38 +0000167
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000168 // At this point, we know the initializer is a constant value 0 and the step
169 // size is a constant value 1. This is our simple induction variable!
170 return true;
Chris Lattnerda956802001-06-21 05:27:22 +0000171}
172
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000173// InjectSimpleInductionVariable - Insert a cannonical induction variable into
174// the interval header Header. This assumes that the flow graph is in
175// simplified form (so we know that the header block has exactly 2 predecessors)
176//
177// TODO: This should inherit the largest type that is being used by the already
178// present induction variables (instead of always using uint)
179//
180static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
Chris Lattner697954c2002-01-20 22:54:45 +0000181 std::string PHIName, AddName;
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000182
183 BasicBlock *Header = Int->getHeaderNode();
184 Method *M = Header->getParent();
185
186 if (M->hasSymbolTable()) {
187 // Only name the induction variable if the method isn't stripped.
188 PHIName = M->getSymbolTable()->getUniqueName(Type::UIntTy, "ind_var");
189 AddName = M->getSymbolTable()->getUniqueName(Type::UIntTy, "ind_var_next");
190 }
191
192 // Create the neccesary instructions...
193 PHINode *PN = new PHINode(Type::UIntTy, PHIName);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000194 Constant *One = ConstantUInt::get(Type::UIntTy, 1);
195 Constant *Zero = ConstantUInt::get(Type::UIntTy, 0);
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000196 BinaryOperator *AddNode = BinaryOperator::create(Instruction::Add,
197 PN, One, AddName);
198
199 // Figure out which predecessors I have to play with... there should be
200 // exactly two... one of which is a loop predecessor, and one of which is not.
201 //
Chris Lattner455889a2002-02-12 22:39:50 +0000202 pred_iterator PI = pred_begin(Header);
203 assert(PI != pred_end(Header) && "Header node should have 2 preds!");
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000204 BasicBlock *Pred1 = *PI; ++PI;
Chris Lattner455889a2002-02-12 22:39:50 +0000205 assert(PI != pred_end(Header) && "Header node should have 2 preds!");
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000206 BasicBlock *Pred2 = *PI;
Chris Lattner455889a2002-02-12 22:39:50 +0000207 assert(++PI == pred_end(Header) && "Header node should have 2 preds!");
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000208
209 // Make Pred1 be the loop entrance predecessor, Pred2 be the Loop predecessor
Chris Lattner697954c2002-01-20 22:54:45 +0000210 if (Int->contains(Pred1)) std::swap(Pred1, Pred2);
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000211
212 assert(!Int->contains(Pred1) && "Pred1 should be loop entrance!");
213 assert( Int->contains(Pred2) && "Pred2 should be looping edge!");
214
215 // Link the instructions into the PHI node...
216 PN->addIncoming(Zero, Pred1); // The initializer is first argument
217 PN->addIncoming(AddNode, Pred2); // The step size is second PHI argument
218
219 // Insert the PHI node into the Header of the loop. It shall be the first
220 // instruction, because the "Simple" Induction Variable must be first in the
221 // block.
222 //
223 BasicBlock::InstListType &IL = Header->getInstList();
224 IL.push_front(PN);
225
226 // Insert the Add instruction as the first (non-phi) instruction in the
227 // header node's basic block.
Chris Lattner3b34c592001-06-27 23:36:09 +0000228 BasicBlock::iterator I = IL.begin();
Chris Lattnerb00c5822001-10-02 03:41:24 +0000229 while (isa<PHINode>(*I)) ++I;
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000230 IL.insert(I, AddNode);
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000231 return PN;
232}
233
Chris Lattner364b1472001-06-22 02:24:38 +0000234// ProcessInterval - This function is invoked once for each interval in the
235// IntervalPartition of the program. It looks for auxilliary induction
236// variables in loops. If it finds one, it:
237// * Cannonicalizes the induction variable. This consists of:
238// A. Making the first element of the PHI node be the loop invariant
239// computation, and the second element be the linear induction portion.
240// B. Changing the first element of the linear induction portion of the PHI
241// node to be of the form ADD(PHI, <loop invariant expr>).
242// * Add the induction variable PHI to a list of induction variables found.
243//
244// After this, a list of cannonical induction variables is known. This list
245// is searched to see if there is an induction variable that counts from
246// constant 0 with a step size of constant 1. If there is not one, one is
247// injected into the loop. Thus a "simple" induction variable is always known
248//
249// One a simple induction variable is known, all other induction variables are
250// modified to refer to the "simple" induction variable.
251//
252static bool ProcessInterval(cfg::Interval *Int) {
253 if (!Int->isLoop()) return false; // Not a loop? Ignore it!
254
Chris Lattner697954c2002-01-20 22:54:45 +0000255 std::vector<PHINode *> InductionVars;
Chris Lattner364b1472001-06-22 02:24:38 +0000256
257 BasicBlock *Header = Int->getHeaderNode();
258 // Loop over all of the PHI nodes in the interval header...
Chris Lattner3b34c592001-06-27 23:36:09 +0000259 for (BasicBlock::iterator I = Header->begin(), E = Header->end();
Chris Lattnerb00c5822001-10-02 03:41:24 +0000260 I != E && isa<PHINode>(*I); ++I) {
261 PHINode *PN = cast<PHINode>(*I);
Chris Lattner364b1472001-06-22 02:24:38 +0000262 if (PN->getNumIncomingValues() != 2) { // These should be eliminated by now.
263 cerr << "Found interval header with more than 2 predecessors! Ignoring\n";
264 return false; // Todo, make an assertion.
265 }
266
267 // For this to be an induction variable, one of the arguments must be a
268 // loop invariant expression, and the other must be an expression involving
269 // the PHI node, along with possible additions and subtractions of loop
270 // invariant values.
271 //
272 BasicBlock *BB1 = PN->getIncomingBlock(0);
273 Value *V1 = PN->getIncomingValue(0);
274 BasicBlock *BB2 = PN->getIncomingBlock(1);
275 Value *V2 = PN->getIncomingValue(1);
276
277 // Figure out which computation is loop invariant...
278 if (!isLoopInvariant(Int, V1)) {
279 // V1 is *not* loop invariant. Check to see if V2 is:
280 if (isLoopInvariant(Int, V2)) {
281 // They *are* loop invariant. Exchange BB1/BB2 and V1/V2 so that
282 // V1 is always the loop invariant computation.
Chris Lattner697954c2002-01-20 22:54:45 +0000283 std::swap(V1, V2); std::swap(BB1, BB2);
Chris Lattner364b1472001-06-22 02:24:38 +0000284 } else {
285 // Neither value is loop invariant. Must not be an induction variable.
286 // This case can happen if there is an unreachable loop in the CFG that
287 // has two tail loops in it that was not split by the cleanup phase
288 // before.
289 continue;
290 }
291 }
292
293 // At this point, we know that BB1/V1 are loop invariant. We don't know
294 // anything about BB2/V2. Check now to see if V2 is a linear induction
295 // variable.
296 //
Chris Lattner697954c2002-01-20 22:54:45 +0000297 cerr << "Found loop invariant computation: " << V1 << "\n";
Chris Lattner364b1472001-06-22 02:24:38 +0000298
299 if (!isLinearInductionVariable(Int, V2, PN))
300 continue; // No, it is not a linear ind var, ignore the PHI node.
301 cerr << "Found linear induction variable: " << V2;
302
303 // TODO: Cannonicalize V2
304
305 // Add this PHI node to the list of induction variables found...
306 InductionVars.push_back(PN);
307 }
308
309 // No induction variables found?
310 if (InductionVars.empty()) return false;
311
Chris Lattner364b1472001-06-22 02:24:38 +0000312 // Search to see if there is already a "simple" induction variable.
Chris Lattner697954c2002-01-20 22:54:45 +0000313 std::vector<PHINode*>::iterator It =
Chris Lattner364b1472001-06-22 02:24:38 +0000314 find_if(InductionVars.begin(), InductionVars.end(), isSimpleInductionVar);
315
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000316 PHINode *PrimaryIndVar;
317
Chris Lattner364b1472001-06-22 02:24:38 +0000318 // A simple induction variable was not found, inject one now...
319 if (It == InductionVars.end()) {
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000320 PrimaryIndVar = InjectSimpleInductionVariable(Int);
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000321 } else {
322 // Move the PHI node for this induction variable to the start of the PHI
323 // list in HeaderNode... we do not need to do this for the inserted case
324 // because the inserted node will always be placed at the beginning of
325 // HeaderNode.
326 //
327 PrimaryIndVar = *It;
Chris Lattner3b34c592001-06-27 23:36:09 +0000328 BasicBlock::iterator i =
329 find(Header->begin(), Header->end(), PrimaryIndVar);
330 assert(i != Header->end() &&
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000331 "How could Primary IndVar not be in the header!?!!?");
332
Chris Lattner3b34c592001-06-27 23:36:09 +0000333 if (i != Header->begin())
Chris Lattner697954c2002-01-20 22:54:45 +0000334 std::iter_swap(i, Header->begin());
Chris Lattner364b1472001-06-22 02:24:38 +0000335 }
336
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000337 // Now we know that there is a simple induction variable PrimaryIndVar.
338 // Simplify all of the other induction variables to use this induction
339 // variable as their counter, and destroy the PHI nodes that correspond to
340 // the old indvars.
Chris Lattner364b1472001-06-22 02:24:38 +0000341 //
342 // TODO
343
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000344
345 cerr << "Found Interval Header with indvars (primary indvar should be first "
Chris Lattner3b34c592001-06-27 23:36:09 +0000346 << "phi): \n" << Header << "\nPrimaryIndVar: " << PrimaryIndVar;
Chris Lattnerc9f39b22001-06-24 04:05:45 +0000347
Chris Lattner364b1472001-06-22 02:24:38 +0000348 return false; // TODO: true;
349}
350
351
352// ProcessIntervalPartition - This function loops over the interval partition
353// processing each interval with ProcessInterval
354//
Chris Lattnerda956802001-06-21 05:27:22 +0000355static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) {
356 // This currently just prints out information about the interval structure
357 // of the method...
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000358#if 0
Chris Lattnerda956802001-06-21 05:27:22 +0000359 static unsigned N = 0;
360 cerr << "\n***********Interval Partition #" << (++N) << "************\n\n";
361 copy(IP.begin(), IP.end(), ostream_iterator<cfg::Interval*>(cerr, "\n"));
362
363 cerr << "\n*********** PERFORMING WORK ************\n\n";
Chris Lattnerd473a0a2001-06-25 07:32:19 +0000364#endif
Chris Lattnerda956802001-06-21 05:27:22 +0000365 // Loop over all of the intervals in the partition and look for induction
366 // variables in intervals that represent loops.
367 //
368 return reduce_apply(IP.begin(), IP.end(), bitwise_or<bool>(), false,
Chris Lattner697954c2002-01-20 22:54:45 +0000369 std::ptr_fun(ProcessInterval));
Chris Lattnerd213f0f2001-06-20 19:27:11 +0000370}
371
Chris Lattner364b1472001-06-22 02:24:38 +0000372// DoInductionVariableCannonicalize - Simplify induction variables in loops.
373// This function loops over an interval partition of a program, reducing it
374// until the graph is gone.
Chris Lattnerd213f0f2001-06-20 19:27:11 +0000375//
Chris Lattner793c6b82002-01-31 00:45:11 +0000376bool InductionVariableCannonicalize::doIt(Method *M,
377 cfg::IntervalPartition &IP) {
Chris Lattnerda956802001-06-21 05:27:22 +0000378 bool Changed = false;
Chris Lattnerd213f0f2001-06-20 19:27:11 +0000379
Chris Lattner793c6b82002-01-31 00:45:11 +0000380#if 0
Chris Lattnerda956802001-06-21 05:27:22 +0000381 while (!IP->isDegeneratePartition()) {
382 Changed |= ProcessIntervalPartition(*IP);
Chris Lattner56832052001-06-20 22:44:38 +0000383
Chris Lattnerda956802001-06-21 05:27:22 +0000384 // Calculate the reduced version of this graph until we get to an
385 // irreducible graph or a degenerate graph...
386 //
387 cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, false);
388 if (NewIP->size() == IP->size()) {
389 cerr << "IRREDUCIBLE GRAPH FOUND!!!\n";
390 return Changed;
391 }
392 delete IP;
393 IP = NewIP;
394 }
Chris Lattner56832052001-06-20 22:44:38 +0000395
Chris Lattnerda956802001-06-21 05:27:22 +0000396 delete IP;
Chris Lattner793c6b82002-01-31 00:45:11 +0000397#endif
Chris Lattnerda956802001-06-21 05:27:22 +0000398 return Changed;
Chris Lattnerd213f0f2001-06-20 19:27:11 +0000399}
Chris Lattner793c6b82002-01-31 00:45:11 +0000400
401
402bool InductionVariableCannonicalize::runOnMethod(Method *M) {
403 return doIt(M, getAnalysis<cfg::IntervalPartition>());
404}
405
406// getAnalysisUsageInfo - This function works on the call graph of a module.
407// It is capable of updating the call graph to reflect the new state of the
408// module.
409//
410void InductionVariableCannonicalize::getAnalysisUsageInfo(
411 Pass::AnalysisSet &Required,
412 Pass::AnalysisSet &Destroyed,
413 Pass::AnalysisSet &Provided) {
414 Required.push_back(cfg::IntervalPartition::ID);
415}