blob: c8f87759767edca992f5002b56fb31742eb7262d [file] [log] [blame]
Chris Lattnerd80e9732002-04-28 00:47:11 +00001//===-- GCSE.cpp - SSA based Global Common Subexpr Elimination ------------===//
2//
3// This pass is designed to be a very quick global transformation that
4// eliminates global common subexpressions from a function. It does this by
5// examining the SSA value graph of the function, instead of doing slow, dense,
6// bit-vector computations.
7//
8// This pass works best if it is proceeded with a simple constant propogation
9// pass and an instruction combination pass because this pass does not do any
10// value numbering (in order to be speedy).
11//
12// This pass does not attempt to CSE load instructions, because it does not use
13// pointer analysis to determine when it is safe.
14//
15//===----------------------------------------------------------------------===//
16
Chris Lattner022103b2002-05-07 20:03:00 +000017#include "llvm/Transforms/Scalar.h"
Chris Lattnerd80e9732002-04-28 00:47:11 +000018#include "llvm/InstrTypes.h"
19#include "llvm/iMemory.h"
20#include "llvm/Analysis/Dominators.h"
21#include "llvm/Support/InstVisitor.h"
22#include "llvm/Support/InstIterator.h"
Chris Lattner18fb2a62002-05-14 05:02:40 +000023#include "llvm/Support/CFG.h"
Chris Lattner3dec1f22002-05-10 15:38:35 +000024#include "Support/StatisticReporter.h"
Chris Lattnerd80e9732002-04-28 00:47:11 +000025#include <algorithm>
Anand Shukla5ba99bd2002-06-25 21:07:58 +000026using std::set;
27using std::map;
28
Chris Lattnerd80e9732002-04-28 00:47:11 +000029
Chris Lattner3dec1f22002-05-10 15:38:35 +000030static Statistic<> NumInstRemoved("gcse\t\t- Number of instructions removed");
Chris Lattner18fb2a62002-05-14 05:02:40 +000031static Statistic<> NumLoadRemoved("gcse\t\t- Number of loads removed");
Chris Lattner3dec1f22002-05-10 15:38:35 +000032
Chris Lattnerd80e9732002-04-28 00:47:11 +000033namespace {
34 class GCSE : public FunctionPass, public InstVisitor<GCSE, bool> {
Chris Lattner18fb2a62002-05-14 05:02:40 +000035 set<Instruction*> WorkList;
36 DominatorSet *DomSetInfo;
37 ImmediateDominators *ImmDominator;
38
39 // BBContainsStore - Contains a value that indicates whether a basic block
40 // has a store or call instruction in it. This map is demand populated, so
41 // not having an entry means that the basic block has not been scanned yet.
42 //
43 map<BasicBlock*, bool> BBContainsStore;
Chris Lattnerd80e9732002-04-28 00:47:11 +000044 public:
Chris Lattner7e708292002-06-25 16:13:24 +000045 virtual bool runOnFunction(Function &F);
Chris Lattnerd80e9732002-04-28 00:47:11 +000046
47 // Visitation methods, these are invoked depending on the type of
48 // instruction being checked. They should return true if a common
49 // subexpression was folded.
50 //
Chris Lattner7e708292002-06-25 16:13:24 +000051 bool visitUnaryOperator(Instruction &I);
52 bool visitBinaryOperator(Instruction &I);
53 bool visitGetElementPtrInst(GetElementPtrInst &I);
54 bool visitCastInst(CastInst &I){return visitUnaryOperator((Instruction&)I);}
55 bool visitShiftInst(ShiftInst &I) {
56 return visitBinaryOperator((Instruction&)I);
Chris Lattnerd80e9732002-04-28 00:47:11 +000057 }
Chris Lattner7e708292002-06-25 16:13:24 +000058 bool visitLoadInst(LoadInst &LI);
59 bool visitInstruction(Instruction &) { return false; }
Chris Lattnerd80e9732002-04-28 00:47:11 +000060
61 private:
62 void ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI);
63 void CommonSubExpressionFound(Instruction *I, Instruction *Other);
64
Chris Lattner18fb2a62002-05-14 05:02:40 +000065 // TryToRemoveALoad - Try to remove one of L1 or L2. The problem with
66 // removing loads is that intervening stores might make otherwise identical
67 // load's yield different values. To ensure that this is not the case, we
68 // check that there are no intervening stores or calls between the
69 // instructions.
70 //
71 bool TryToRemoveALoad(LoadInst *L1, LoadInst *L2);
72
73 // CheckForInvalidatingInst - Return true if BB or any of the predecessors
74 // of BB (until DestBB) contain a store (or other invalidating) instruction.
75 //
76 bool CheckForInvalidatingInst(BasicBlock *BB, BasicBlock *DestBB,
77 set<BasicBlock*> &VisitedSet);
78
Chris Lattnerd80e9732002-04-28 00:47:11 +000079 // This transformation requires dominator and immediate dominator info
80 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
Chris Lattner97e52e42002-04-28 21:27:06 +000081 AU.preservesCFG();
Chris Lattnerd80e9732002-04-28 00:47:11 +000082 AU.addRequired(DominatorSet::ID);
83 AU.addRequired(ImmediateDominators::ID);
84 }
85 };
Chris Lattnerf6293092002-07-23 18:06:35 +000086
Chris Lattnera6275cc2002-07-26 21:12:46 +000087 RegisterOpt<GCSE> X("gcse", "Global Common Subexpression Elimination");
Chris Lattnerd80e9732002-04-28 00:47:11 +000088}
89
90// createGCSEPass - The public interface to this file...
91Pass *createGCSEPass() { return new GCSE(); }
92
93
94// GCSE::runOnFunction - This is the main transformation entry point for a
95// function.
96//
Chris Lattner7e708292002-06-25 16:13:24 +000097bool GCSE::runOnFunction(Function &F) {
Chris Lattnerd80e9732002-04-28 00:47:11 +000098 bool Changed = false;
99
100 DomSetInfo = &getAnalysis<DominatorSet>();
101 ImmDominator = &getAnalysis<ImmediateDominators>();
102
103 // Step #1: Add all instructions in the function to the worklist for
104 // processing. All of the instructions are considered to be our
105 // subexpressions to eliminate if possible.
106 //
107 WorkList.insert(inst_begin(F), inst_end(F));
108
109 // Step #2: WorkList processing. Iterate through all of the instructions,
110 // checking to see if there are any additionally defined subexpressions in the
111 // program. If so, eliminate them!
112 //
113 while (!WorkList.empty()) {
Chris Lattner7e708292002-06-25 16:13:24 +0000114 Instruction &I = **WorkList.begin(); // Get an instruction from the worklist
Chris Lattnerd80e9732002-04-28 00:47:11 +0000115 WorkList.erase(WorkList.begin());
116
117 // Visit the instruction, dispatching to the correct visit function based on
118 // the instruction type. This does the checking.
119 //
120 Changed |= visit(I);
121 }
Chris Lattner18fb2a62002-05-14 05:02:40 +0000122
123 // Clear out data structure so that next function starts fresh
124 BBContainsStore.clear();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000125
126 // When the worklist is empty, return whether or not we changed anything...
127 return Changed;
128}
129
130
131// ReplaceInstWithInst - Destroy the instruction pointed to by SI, making all
132// uses of the instruction use First now instead.
133//
134void GCSE::ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI) {
Chris Lattner7e708292002-06-25 16:13:24 +0000135 Instruction &Second = *SI;
Chris Lattner8b054c02002-04-29 16:20:25 +0000136
137 //cerr << "DEL " << (void*)Second << Second;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000138
139 // Add the first instruction back to the worklist
140 WorkList.insert(First);
141
142 // Add all uses of the second instruction to the worklist
Chris Lattner7e708292002-06-25 16:13:24 +0000143 for (Value::use_iterator UI = Second.use_begin(), UE = Second.use_end();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000144 UI != UE; ++UI)
145 WorkList.insert(cast<Instruction>(*UI));
146
147 // Make all users of 'Second' now use 'First'
Chris Lattner7e708292002-06-25 16:13:24 +0000148 Second.replaceAllUsesWith(First);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000149
150 // Erase the second instruction from the program
Chris Lattner7e708292002-06-25 16:13:24 +0000151 Second.getParent()->getInstList().erase(SI);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000152}
153
154// CommonSubExpressionFound - The two instruction I & Other have been found to
155// be common subexpressions. This function is responsible for eliminating one
156// of them, and for fixing the worklist to be correct.
157//
158void GCSE::CommonSubExpressionFound(Instruction *I, Instruction *Other) {
Chris Lattner18fb2a62002-05-14 05:02:40 +0000159 assert(I != Other);
Chris Lattner8b054c02002-04-29 16:20:25 +0000160
Chris Lattner18fb2a62002-05-14 05:02:40 +0000161 WorkList.erase(I);
Chris Lattner8b054c02002-04-29 16:20:25 +0000162 WorkList.erase(Other); // Other may not actually be on the worklist anymore...
Chris Lattnerd80e9732002-04-28 00:47:11 +0000163
Chris Lattner3dec1f22002-05-10 15:38:35 +0000164 ++NumInstRemoved; // Keep track of number of instructions eliminated
165
Chris Lattnerd80e9732002-04-28 00:47:11 +0000166 // Handle the easy case, where both instructions are in the same basic block
167 BasicBlock *BB1 = I->getParent(), *BB2 = Other->getParent();
168 if (BB1 == BB2) {
169 // Eliminate the second occuring instruction. Add all uses of the second
170 // instruction to the worklist.
171 //
172 // Scan the basic block looking for the "first" instruction
173 BasicBlock::iterator BI = BB1->begin();
Chris Lattner7e708292002-06-25 16:13:24 +0000174 while (&*BI != I && &*BI != Other) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000175 ++BI;
176 assert(BI != BB1->end() && "Instructions not found in parent BB!");
177 }
178
179 // Keep track of which instructions occurred first & second
Chris Lattner7e708292002-06-25 16:13:24 +0000180 Instruction *First = BI;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000181 Instruction *Second = I != First ? I : Other; // Get iterator to second inst
Chris Lattner7e708292002-06-25 16:13:24 +0000182 BI = Second;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000183
184 // Destroy Second, using First instead.
185 ReplaceInstWithInst(First, BI);
186
187 // Otherwise, the two instructions are in different basic blocks. If one
188 // dominates the other instruction, we can simply use it
189 //
190 } else if (DomSetInfo->dominates(BB1, BB2)) { // I dom Other?
Chris Lattner7e708292002-06-25 16:13:24 +0000191 ReplaceInstWithInst(I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000192 } else if (DomSetInfo->dominates(BB2, BB1)) { // Other dom I?
Chris Lattner7e708292002-06-25 16:13:24 +0000193 ReplaceInstWithInst(Other, I);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000194 } else {
195 // Handle the most general case now. In this case, neither I dom Other nor
196 // Other dom I. Because we are in SSA form, we are guaranteed that the
197 // operands of the two instructions both dominate the uses, so we _know_
198 // that there must exist a block that dominates both instructions (if the
199 // operands of the instructions are globals or constants, worst case we
200 // would get the entry node of the function). Search for this block now.
201 //
202
203 // Search up the immediate dominator chain of BB1 for the shared dominator
204 BasicBlock *SharedDom = (*ImmDominator)[BB1];
205 while (!DomSetInfo->dominates(SharedDom, BB2))
206 SharedDom = (*ImmDominator)[SharedDom];
207
208 // At this point, shared dom must dominate BOTH BB1 and BB2...
209 assert(SharedDom && DomSetInfo->dominates(SharedDom, BB1) &&
210 DomSetInfo->dominates(SharedDom, BB2) && "Dominators broken!");
211
212 // Rip 'I' out of BB1, and move it to the end of SharedDom.
213 BB1->getInstList().remove(I);
Chris Lattner7e708292002-06-25 16:13:24 +0000214 SharedDom->getInstList().insert(--SharedDom->end(), I);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000215
216 // Eliminate 'Other' now.
Chris Lattner7e708292002-06-25 16:13:24 +0000217 ReplaceInstWithInst(I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000218 }
219}
220
221//===----------------------------------------------------------------------===//
222//
223// Visitation methods, these are invoked depending on the type of instruction
224// being checked. They should return true if a common subexpression was folded.
225//
226//===----------------------------------------------------------------------===//
227
Chris Lattner7e708292002-06-25 16:13:24 +0000228bool GCSE::visitUnaryOperator(Instruction &I) {
229 Value *Op = I.getOperand(0);
230 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000231
232 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
233 UI != UE; ++UI)
234 if (Instruction *Other = dyn_cast<Instruction>(*UI))
235 // Check to see if this new binary operator is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000236 if (Other != &I && Other->getOpcode() == I.getOpcode() &&
Chris Lattnerd80e9732002-04-28 00:47:11 +0000237 Other->getOperand(0) == Op && // Is the operand the same?
238 // Is it embeded in the same function? (This could be false if LHS
239 // is a constant or global!)
240 Other->getParent()->getParent() == F &&
241
242 // Check that the types are the same, since this code handles casts...
Chris Lattner7e708292002-06-25 16:13:24 +0000243 Other->getType() == I.getType()) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000244
245 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000246 CommonSubExpressionFound(&I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000247 return true; // One instruction eliminated!
248 }
249
250 return false;
251}
252
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000253// isIdenticalBinaryInst - Return true if the two binary instructions are
254// identical.
255//
Chris Lattner7e708292002-06-25 16:13:24 +0000256static inline bool isIdenticalBinaryInst(const Instruction &I1,
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000257 const Instruction *I2) {
258 // Is it embeded in the same function? (This could be false if LHS
259 // is a constant or global!)
Chris Lattner7e708292002-06-25 16:13:24 +0000260 if (I1.getOpcode() != I2->getOpcode() ||
261 I1.getParent()->getParent() != I2->getParent()->getParent())
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000262 return false;
263
264 // They are identical if both operands are the same!
Chris Lattner7e708292002-06-25 16:13:24 +0000265 if (I1.getOperand(0) == I2->getOperand(0) &&
266 I1.getOperand(1) == I2->getOperand(1))
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000267 return true;
268
269 // If the instruction is commutative and associative, the instruction can
270 // match if the operands are swapped!
271 //
Chris Lattner7e708292002-06-25 16:13:24 +0000272 if ((I1.getOperand(0) == I2->getOperand(1) &&
273 I1.getOperand(1) == I2->getOperand(0)) &&
274 (I1.getOpcode() == Instruction::Add ||
275 I1.getOpcode() == Instruction::Mul ||
276 I1.getOpcode() == Instruction::And ||
277 I1.getOpcode() == Instruction::Or ||
278 I1.getOpcode() == Instruction::Xor))
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000279 return true;
280
281 return false;
282}
283
Chris Lattner7e708292002-06-25 16:13:24 +0000284bool GCSE::visitBinaryOperator(Instruction &I) {
285 Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
286 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000287
288 for (Value::use_iterator UI = LHS->use_begin(), UE = LHS->use_end();
289 UI != UE; ++UI)
290 if (Instruction *Other = dyn_cast<Instruction>(*UI))
291 // Check to see if this new binary operator is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000292 if (Other != &I && isIdenticalBinaryInst(I, Other)) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000293 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000294 CommonSubExpressionFound(&I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000295 return true; // One instruction eliminated!
296 }
297
298 return false;
299}
300
Chris Lattner18fb2a62002-05-14 05:02:40 +0000301// IdenticalComplexInst - Return true if the two instructions are the same, by
302// using a brute force comparison.
303//
304static bool IdenticalComplexInst(const Instruction *I1, const Instruction *I2) {
305 assert(I1->getOpcode() == I2->getOpcode());
306 // Equal if they are in the same function...
307 return I1->getParent()->getParent() == I2->getParent()->getParent() &&
308 // And return the same type...
309 I1->getType() == I2->getType() &&
310 // And have the same number of operands...
311 I1->getNumOperands() == I2->getNumOperands() &&
312 // And all of the operands are equal.
313 std::equal(I1->op_begin(), I1->op_end(), I2->op_begin());
314}
315
Chris Lattner7e708292002-06-25 16:13:24 +0000316bool GCSE::visitGetElementPtrInst(GetElementPtrInst &I) {
317 Value *Op = I.getOperand(0);
318 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000319
320 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
321 UI != UE; ++UI)
322 if (GetElementPtrInst *Other = dyn_cast<GetElementPtrInst>(*UI))
Chris Lattner18fb2a62002-05-14 05:02:40 +0000323 // Check to see if this new getelementptr is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000324 if (Other != &I && IdenticalComplexInst(&I, Other)) {
Chris Lattner18fb2a62002-05-14 05:02:40 +0000325 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000326 CommonSubExpressionFound(&I, Other);
Chris Lattner18fb2a62002-05-14 05:02:40 +0000327 return true; // One instruction eliminated!
Chris Lattnerd80e9732002-04-28 00:47:11 +0000328 }
329
330 return false;
331}
Chris Lattner18fb2a62002-05-14 05:02:40 +0000332
Chris Lattner7e708292002-06-25 16:13:24 +0000333bool GCSE::visitLoadInst(LoadInst &LI) {
334 Value *Op = LI.getOperand(0);
335 Function *F = LI.getParent()->getParent();
Chris Lattner18fb2a62002-05-14 05:02:40 +0000336
337 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
338 UI != UE; ++UI)
339 if (LoadInst *Other = dyn_cast<LoadInst>(*UI))
340 // Check to see if this new load is not LI, but has the same operands...
Chris Lattner7e708292002-06-25 16:13:24 +0000341 if (Other != &LI && IdenticalComplexInst(&LI, Other) &&
342 TryToRemoveALoad(&LI, Other))
Chris Lattner18fb2a62002-05-14 05:02:40 +0000343 return true; // An instruction was eliminated!
344
345 return false;
346}
347
Chris Lattner7e708292002-06-25 16:13:24 +0000348static inline bool isInvalidatingInst(const Instruction &I) {
349 return I.getOpcode() == Instruction::Store ||
350 I.getOpcode() == Instruction::Call ||
351 I.getOpcode() == Instruction::Invoke;
Chris Lattner18fb2a62002-05-14 05:02:40 +0000352}
353
354// TryToRemoveALoad - Try to remove one of L1 or L2. The problem with removing
355// loads is that intervening stores might make otherwise identical load's yield
356// different values. To ensure that this is not the case, we check that there
357// are no intervening stores or calls between the instructions.
358//
359bool GCSE::TryToRemoveALoad(LoadInst *L1, LoadInst *L2) {
360 // Figure out which load dominates the other one. If neither dominates the
361 // other we cannot eliminate one...
362 //
363 if (DomSetInfo->dominates(L2, L1))
364 std::swap(L1, L2); // Make L1 dominate L2
365 else if (!DomSetInfo->dominates(L1, L2))
366 return false; // Neither instruction dominates the other one...
367
368 BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent();
369
Chris Lattner7e708292002-06-25 16:13:24 +0000370 BasicBlock::iterator L1I = L1;
Chris Lattner18fb2a62002-05-14 05:02:40 +0000371
372 // L1 now dominates L2. Check to see if the intervening instructions between
373 // the two loads include a store or call...
374 //
375 if (BB1 == BB2) { // In same basic block?
376 // In this degenerate case, no checking of global basic blocks has to occur
377 // just check the instructions BETWEEN L1 & L2...
378 //
Chris Lattner7e708292002-06-25 16:13:24 +0000379 for (++L1I; &*L1I != L2; ++L1I)
Chris Lattner18fb2a62002-05-14 05:02:40 +0000380 if (isInvalidatingInst(*L1I))
381 return false; // Cannot eliminate load
382
383 ++NumLoadRemoved;
384 CommonSubExpressionFound(L1, L2);
385 return true;
386 } else {
387 // Make sure that there are no store instructions between L1 and the end of
388 // it's basic block...
389 //
390 for (++L1I; L1I != BB1->end(); ++L1I)
391 if (isInvalidatingInst(*L1I)) {
392 BBContainsStore[BB1] = true;
393 return false; // Cannot eliminate load
394 }
395
396 // Make sure that there are no store instructions between the start of BB2
397 // and the second load instruction...
398 //
Chris Lattner7e708292002-06-25 16:13:24 +0000399 for (BasicBlock::iterator II = BB2->begin(); &*II != L2; ++II)
Chris Lattner18fb2a62002-05-14 05:02:40 +0000400 if (isInvalidatingInst(*II)) {
401 BBContainsStore[BB2] = true;
402 return false; // Cannot eliminate load
403 }
404
405 // Do a depth first traversal of the inverse CFG starting at L2's block,
406 // looking for L1's block. The inverse CFG is made up of the predecessor
407 // nodes of a block... so all of the edges in the graph are "backward".
408 //
409 set<BasicBlock*> VisitedSet;
410 for (pred_iterator PI = pred_begin(BB2), PE = pred_end(BB2); PI != PE; ++PI)
411 if (CheckForInvalidatingInst(*PI, BB1, VisitedSet))
412 return false;
413
414 ++NumLoadRemoved;
415 CommonSubExpressionFound(L1, L2);
416 return true;
417 }
418 return false;
419}
420
421// CheckForInvalidatingInst - Return true if BB or any of the predecessors of BB
422// (until DestBB) contain a store (or other invalidating) instruction.
423//
424bool GCSE::CheckForInvalidatingInst(BasicBlock *BB, BasicBlock *DestBB,
425 set<BasicBlock*> &VisitedSet) {
426 // Found the termination point!
427 if (BB == DestBB || VisitedSet.count(BB)) return false;
428
429 // Avoid infinite recursion!
430 VisitedSet.insert(BB);
431
432 // Have we already checked this block?
433 map<BasicBlock*, bool>::iterator MI = BBContainsStore.find(BB);
434
435 if (MI != BBContainsStore.end()) {
436 // If this block is known to contain a store, exit the recursion early...
437 if (MI->second) return true;
438 // Otherwise continue checking predecessors...
439 } else {
440 // We don't know if this basic block contains an invalidating instruction.
441 // Check now:
442 bool HasStore = std::find_if(BB->begin(), BB->end(),
443 isInvalidatingInst) != BB->end();
444 if ((BBContainsStore[BB] = HasStore)) // Update map
445 return true; // Exit recursion early...
446 }
447
448 // Check all of our predecessor blocks...
449 for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI)
450 if (CheckForInvalidatingInst(*PI, DestBB, VisitedSet))
451 return true;
452
453 // None of our predecessor blocks contain a store, and we don't either!
454 return false;
455}