blob: 56bb191e16dd474a16323ca177b39ce0e4a5e15d [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 Lattner96c466b2002-04-29 14:57:45 +000045 const char *getPassName() const {
46 return "Global Common Subexpression Elimination";
47 }
48
Chris Lattner7e708292002-06-25 16:13:24 +000049 virtual bool runOnFunction(Function &F);
Chris Lattnerd80e9732002-04-28 00:47:11 +000050
51 // Visitation methods, these are invoked depending on the type of
52 // instruction being checked. They should return true if a common
53 // subexpression was folded.
54 //
Chris Lattner7e708292002-06-25 16:13:24 +000055 bool visitUnaryOperator(Instruction &I);
56 bool visitBinaryOperator(Instruction &I);
57 bool visitGetElementPtrInst(GetElementPtrInst &I);
58 bool visitCastInst(CastInst &I){return visitUnaryOperator((Instruction&)I);}
59 bool visitShiftInst(ShiftInst &I) {
60 return visitBinaryOperator((Instruction&)I);
Chris Lattnerd80e9732002-04-28 00:47:11 +000061 }
Chris Lattner7e708292002-06-25 16:13:24 +000062 bool visitLoadInst(LoadInst &LI);
63 bool visitInstruction(Instruction &) { return false; }
Chris Lattnerd80e9732002-04-28 00:47:11 +000064
65 private:
66 void ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI);
67 void CommonSubExpressionFound(Instruction *I, Instruction *Other);
68
Chris Lattner18fb2a62002-05-14 05:02:40 +000069 // TryToRemoveALoad - Try to remove one of L1 or L2. The problem with
70 // removing loads is that intervening stores might make otherwise identical
71 // load's yield different values. To ensure that this is not the case, we
72 // check that there are no intervening stores or calls between the
73 // instructions.
74 //
75 bool TryToRemoveALoad(LoadInst *L1, LoadInst *L2);
76
77 // CheckForInvalidatingInst - Return true if BB or any of the predecessors
78 // of BB (until DestBB) contain a store (or other invalidating) instruction.
79 //
80 bool CheckForInvalidatingInst(BasicBlock *BB, BasicBlock *DestBB,
81 set<BasicBlock*> &VisitedSet);
82
Chris Lattnerd80e9732002-04-28 00:47:11 +000083 // This transformation requires dominator and immediate dominator info
84 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
Chris Lattner97e52e42002-04-28 21:27:06 +000085 AU.preservesCFG();
Chris Lattnerd80e9732002-04-28 00:47:11 +000086 AU.addRequired(DominatorSet::ID);
87 AU.addRequired(ImmediateDominators::ID);
88 }
89 };
90}
91
92// createGCSEPass - The public interface to this file...
93Pass *createGCSEPass() { return new GCSE(); }
94
95
96// GCSE::runOnFunction - This is the main transformation entry point for a
97// function.
98//
Chris Lattner7e708292002-06-25 16:13:24 +000099bool GCSE::runOnFunction(Function &F) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000100 bool Changed = false;
101
102 DomSetInfo = &getAnalysis<DominatorSet>();
103 ImmDominator = &getAnalysis<ImmediateDominators>();
104
105 // Step #1: Add all instructions in the function to the worklist for
106 // processing. All of the instructions are considered to be our
107 // subexpressions to eliminate if possible.
108 //
109 WorkList.insert(inst_begin(F), inst_end(F));
110
111 // Step #2: WorkList processing. Iterate through all of the instructions,
112 // checking to see if there are any additionally defined subexpressions in the
113 // program. If so, eliminate them!
114 //
115 while (!WorkList.empty()) {
Chris Lattner7e708292002-06-25 16:13:24 +0000116 Instruction &I = **WorkList.begin(); // Get an instruction from the worklist
Chris Lattnerd80e9732002-04-28 00:47:11 +0000117 WorkList.erase(WorkList.begin());
118
119 // Visit the instruction, dispatching to the correct visit function based on
120 // the instruction type. This does the checking.
121 //
122 Changed |= visit(I);
123 }
Chris Lattner18fb2a62002-05-14 05:02:40 +0000124
125 // Clear out data structure so that next function starts fresh
126 BBContainsStore.clear();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000127
128 // When the worklist is empty, return whether or not we changed anything...
129 return Changed;
130}
131
132
133// ReplaceInstWithInst - Destroy the instruction pointed to by SI, making all
134// uses of the instruction use First now instead.
135//
136void GCSE::ReplaceInstWithInst(Instruction *First, BasicBlock::iterator SI) {
Chris Lattner7e708292002-06-25 16:13:24 +0000137 Instruction &Second = *SI;
Chris Lattner8b054c02002-04-29 16:20:25 +0000138
139 //cerr << "DEL " << (void*)Second << Second;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000140
141 // Add the first instruction back to the worklist
142 WorkList.insert(First);
143
144 // Add all uses of the second instruction to the worklist
Chris Lattner7e708292002-06-25 16:13:24 +0000145 for (Value::use_iterator UI = Second.use_begin(), UE = Second.use_end();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000146 UI != UE; ++UI)
147 WorkList.insert(cast<Instruction>(*UI));
148
149 // Make all users of 'Second' now use 'First'
Chris Lattner7e708292002-06-25 16:13:24 +0000150 Second.replaceAllUsesWith(First);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000151
152 // Erase the second instruction from the program
Chris Lattner7e708292002-06-25 16:13:24 +0000153 Second.getParent()->getInstList().erase(SI);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000154}
155
156// CommonSubExpressionFound - The two instruction I & Other have been found to
157// be common subexpressions. This function is responsible for eliminating one
158// of them, and for fixing the worklist to be correct.
159//
160void GCSE::CommonSubExpressionFound(Instruction *I, Instruction *Other) {
Chris Lattner18fb2a62002-05-14 05:02:40 +0000161 assert(I != Other);
Chris Lattner8b054c02002-04-29 16:20:25 +0000162
Chris Lattner18fb2a62002-05-14 05:02:40 +0000163 WorkList.erase(I);
Chris Lattner8b054c02002-04-29 16:20:25 +0000164 WorkList.erase(Other); // Other may not actually be on the worklist anymore...
Chris Lattnerd80e9732002-04-28 00:47:11 +0000165
Chris Lattner3dec1f22002-05-10 15:38:35 +0000166 ++NumInstRemoved; // Keep track of number of instructions eliminated
167
Chris Lattnerd80e9732002-04-28 00:47:11 +0000168 // Handle the easy case, where both instructions are in the same basic block
169 BasicBlock *BB1 = I->getParent(), *BB2 = Other->getParent();
170 if (BB1 == BB2) {
171 // Eliminate the second occuring instruction. Add all uses of the second
172 // instruction to the worklist.
173 //
174 // Scan the basic block looking for the "first" instruction
175 BasicBlock::iterator BI = BB1->begin();
Chris Lattner7e708292002-06-25 16:13:24 +0000176 while (&*BI != I && &*BI != Other) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000177 ++BI;
178 assert(BI != BB1->end() && "Instructions not found in parent BB!");
179 }
180
181 // Keep track of which instructions occurred first & second
Chris Lattner7e708292002-06-25 16:13:24 +0000182 Instruction *First = BI;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000183 Instruction *Second = I != First ? I : Other; // Get iterator to second inst
Chris Lattner7e708292002-06-25 16:13:24 +0000184 BI = Second;
Chris Lattnerd80e9732002-04-28 00:47:11 +0000185
186 // Destroy Second, using First instead.
187 ReplaceInstWithInst(First, BI);
188
189 // Otherwise, the two instructions are in different basic blocks. If one
190 // dominates the other instruction, we can simply use it
191 //
192 } else if (DomSetInfo->dominates(BB1, BB2)) { // I dom Other?
Chris Lattner7e708292002-06-25 16:13:24 +0000193 ReplaceInstWithInst(I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000194 } else if (DomSetInfo->dominates(BB2, BB1)) { // Other dom I?
Chris Lattner7e708292002-06-25 16:13:24 +0000195 ReplaceInstWithInst(Other, I);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000196 } else {
197 // Handle the most general case now. In this case, neither I dom Other nor
198 // Other dom I. Because we are in SSA form, we are guaranteed that the
199 // operands of the two instructions both dominate the uses, so we _know_
200 // that there must exist a block that dominates both instructions (if the
201 // operands of the instructions are globals or constants, worst case we
202 // would get the entry node of the function). Search for this block now.
203 //
204
205 // Search up the immediate dominator chain of BB1 for the shared dominator
206 BasicBlock *SharedDom = (*ImmDominator)[BB1];
207 while (!DomSetInfo->dominates(SharedDom, BB2))
208 SharedDom = (*ImmDominator)[SharedDom];
209
210 // At this point, shared dom must dominate BOTH BB1 and BB2...
211 assert(SharedDom && DomSetInfo->dominates(SharedDom, BB1) &&
212 DomSetInfo->dominates(SharedDom, BB2) && "Dominators broken!");
213
214 // Rip 'I' out of BB1, and move it to the end of SharedDom.
215 BB1->getInstList().remove(I);
Chris Lattner7e708292002-06-25 16:13:24 +0000216 SharedDom->getInstList().insert(--SharedDom->end(), I);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000217
218 // Eliminate 'Other' now.
Chris Lattner7e708292002-06-25 16:13:24 +0000219 ReplaceInstWithInst(I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000220 }
221}
222
223//===----------------------------------------------------------------------===//
224//
225// Visitation methods, these are invoked depending on the type of instruction
226// being checked. They should return true if a common subexpression was folded.
227//
228//===----------------------------------------------------------------------===//
229
Chris Lattner7e708292002-06-25 16:13:24 +0000230bool GCSE::visitUnaryOperator(Instruction &I) {
231 Value *Op = I.getOperand(0);
232 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000233
234 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
235 UI != UE; ++UI)
236 if (Instruction *Other = dyn_cast<Instruction>(*UI))
237 // Check to see if this new binary operator is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000238 if (Other != &I && Other->getOpcode() == I.getOpcode() &&
Chris Lattnerd80e9732002-04-28 00:47:11 +0000239 Other->getOperand(0) == Op && // Is the operand the same?
240 // Is it embeded in the same function? (This could be false if LHS
241 // is a constant or global!)
242 Other->getParent()->getParent() == F &&
243
244 // Check that the types are the same, since this code handles casts...
Chris Lattner7e708292002-06-25 16:13:24 +0000245 Other->getType() == I.getType()) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000246
247 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000248 CommonSubExpressionFound(&I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000249 return true; // One instruction eliminated!
250 }
251
252 return false;
253}
254
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000255// isIdenticalBinaryInst - Return true if the two binary instructions are
256// identical.
257//
Chris Lattner7e708292002-06-25 16:13:24 +0000258static inline bool isIdenticalBinaryInst(const Instruction &I1,
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000259 const Instruction *I2) {
260 // Is it embeded in the same function? (This could be false if LHS
261 // is a constant or global!)
Chris Lattner7e708292002-06-25 16:13:24 +0000262 if (I1.getOpcode() != I2->getOpcode() ||
263 I1.getParent()->getParent() != I2->getParent()->getParent())
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000264 return false;
265
266 // They are identical if both operands are the same!
Chris Lattner7e708292002-06-25 16:13:24 +0000267 if (I1.getOperand(0) == I2->getOperand(0) &&
268 I1.getOperand(1) == I2->getOperand(1))
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000269 return true;
270
271 // If the instruction is commutative and associative, the instruction can
272 // match if the operands are swapped!
273 //
Chris Lattner7e708292002-06-25 16:13:24 +0000274 if ((I1.getOperand(0) == I2->getOperand(1) &&
275 I1.getOperand(1) == I2->getOperand(0)) &&
276 (I1.getOpcode() == Instruction::Add ||
277 I1.getOpcode() == Instruction::Mul ||
278 I1.getOpcode() == Instruction::And ||
279 I1.getOpcode() == Instruction::Or ||
280 I1.getOpcode() == Instruction::Xor))
Chris Lattner0f9fd5b2002-05-14 19:57:25 +0000281 return true;
282
283 return false;
284}
285
Chris Lattner7e708292002-06-25 16:13:24 +0000286bool GCSE::visitBinaryOperator(Instruction &I) {
287 Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
288 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000289
290 for (Value::use_iterator UI = LHS->use_begin(), UE = LHS->use_end();
291 UI != UE; ++UI)
292 if (Instruction *Other = dyn_cast<Instruction>(*UI))
293 // Check to see if this new binary operator is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000294 if (Other != &I && isIdenticalBinaryInst(I, Other)) {
Chris Lattnerd80e9732002-04-28 00:47:11 +0000295 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000296 CommonSubExpressionFound(&I, Other);
Chris Lattnerd80e9732002-04-28 00:47:11 +0000297 return true; // One instruction eliminated!
298 }
299
300 return false;
301}
302
Chris Lattner18fb2a62002-05-14 05:02:40 +0000303// IdenticalComplexInst - Return true if the two instructions are the same, by
304// using a brute force comparison.
305//
306static bool IdenticalComplexInst(const Instruction *I1, const Instruction *I2) {
307 assert(I1->getOpcode() == I2->getOpcode());
308 // Equal if they are in the same function...
309 return I1->getParent()->getParent() == I2->getParent()->getParent() &&
310 // And return the same type...
311 I1->getType() == I2->getType() &&
312 // And have the same number of operands...
313 I1->getNumOperands() == I2->getNumOperands() &&
314 // And all of the operands are equal.
315 std::equal(I1->op_begin(), I1->op_end(), I2->op_begin());
316}
317
Chris Lattner7e708292002-06-25 16:13:24 +0000318bool GCSE::visitGetElementPtrInst(GetElementPtrInst &I) {
319 Value *Op = I.getOperand(0);
320 Function *F = I.getParent()->getParent();
Chris Lattnerd80e9732002-04-28 00:47:11 +0000321
322 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
323 UI != UE; ++UI)
324 if (GetElementPtrInst *Other = dyn_cast<GetElementPtrInst>(*UI))
Chris Lattner18fb2a62002-05-14 05:02:40 +0000325 // Check to see if this new getelementptr is not I, but same operand...
Chris Lattner7e708292002-06-25 16:13:24 +0000326 if (Other != &I && IdenticalComplexInst(&I, Other)) {
Chris Lattner18fb2a62002-05-14 05:02:40 +0000327 // These instructions are identical. Handle the situation.
Chris Lattner7e708292002-06-25 16:13:24 +0000328 CommonSubExpressionFound(&I, Other);
Chris Lattner18fb2a62002-05-14 05:02:40 +0000329 return true; // One instruction eliminated!
Chris Lattnerd80e9732002-04-28 00:47:11 +0000330 }
331
332 return false;
333}
Chris Lattner18fb2a62002-05-14 05:02:40 +0000334
Chris Lattner7e708292002-06-25 16:13:24 +0000335bool GCSE::visitLoadInst(LoadInst &LI) {
336 Value *Op = LI.getOperand(0);
337 Function *F = LI.getParent()->getParent();
Chris Lattner18fb2a62002-05-14 05:02:40 +0000338
339 for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
340 UI != UE; ++UI)
341 if (LoadInst *Other = dyn_cast<LoadInst>(*UI))
342 // Check to see if this new load is not LI, but has the same operands...
Chris Lattner7e708292002-06-25 16:13:24 +0000343 if (Other != &LI && IdenticalComplexInst(&LI, Other) &&
344 TryToRemoveALoad(&LI, Other))
Chris Lattner18fb2a62002-05-14 05:02:40 +0000345 return true; // An instruction was eliminated!
346
347 return false;
348}
349
Chris Lattner7e708292002-06-25 16:13:24 +0000350static inline bool isInvalidatingInst(const Instruction &I) {
351 return I.getOpcode() == Instruction::Store ||
352 I.getOpcode() == Instruction::Call ||
353 I.getOpcode() == Instruction::Invoke;
Chris Lattner18fb2a62002-05-14 05:02:40 +0000354}
355
356// TryToRemoveALoad - Try to remove one of L1 or L2. The problem with removing
357// loads is that intervening stores might make otherwise identical load's yield
358// different values. To ensure that this is not the case, we check that there
359// are no intervening stores or calls between the instructions.
360//
361bool GCSE::TryToRemoveALoad(LoadInst *L1, LoadInst *L2) {
362 // Figure out which load dominates the other one. If neither dominates the
363 // other we cannot eliminate one...
364 //
365 if (DomSetInfo->dominates(L2, L1))
366 std::swap(L1, L2); // Make L1 dominate L2
367 else if (!DomSetInfo->dominates(L1, L2))
368 return false; // Neither instruction dominates the other one...
369
370 BasicBlock *BB1 = L1->getParent(), *BB2 = L2->getParent();
371
Chris Lattner7e708292002-06-25 16:13:24 +0000372 BasicBlock::iterator L1I = L1;
Chris Lattner18fb2a62002-05-14 05:02:40 +0000373
374 // L1 now dominates L2. Check to see if the intervening instructions between
375 // the two loads include a store or call...
376 //
377 if (BB1 == BB2) { // In same basic block?
378 // In this degenerate case, no checking of global basic blocks has to occur
379 // just check the instructions BETWEEN L1 & L2...
380 //
Chris Lattner7e708292002-06-25 16:13:24 +0000381 for (++L1I; &*L1I != L2; ++L1I)
Chris Lattner18fb2a62002-05-14 05:02:40 +0000382 if (isInvalidatingInst(*L1I))
383 return false; // Cannot eliminate load
384
385 ++NumLoadRemoved;
386 CommonSubExpressionFound(L1, L2);
387 return true;
388 } else {
389 // Make sure that there are no store instructions between L1 and the end of
390 // it's basic block...
391 //
392 for (++L1I; L1I != BB1->end(); ++L1I)
393 if (isInvalidatingInst(*L1I)) {
394 BBContainsStore[BB1] = true;
395 return false; // Cannot eliminate load
396 }
397
398 // Make sure that there are no store instructions between the start of BB2
399 // and the second load instruction...
400 //
Chris Lattner7e708292002-06-25 16:13:24 +0000401 for (BasicBlock::iterator II = BB2->begin(); &*II != L2; ++II)
Chris Lattner18fb2a62002-05-14 05:02:40 +0000402 if (isInvalidatingInst(*II)) {
403 BBContainsStore[BB2] = true;
404 return false; // Cannot eliminate load
405 }
406
407 // Do a depth first traversal of the inverse CFG starting at L2's block,
408 // looking for L1's block. The inverse CFG is made up of the predecessor
409 // nodes of a block... so all of the edges in the graph are "backward".
410 //
411 set<BasicBlock*> VisitedSet;
412 for (pred_iterator PI = pred_begin(BB2), PE = pred_end(BB2); PI != PE; ++PI)
413 if (CheckForInvalidatingInst(*PI, BB1, VisitedSet))
414 return false;
415
416 ++NumLoadRemoved;
417 CommonSubExpressionFound(L1, L2);
418 return true;
419 }
420 return false;
421}
422
423// CheckForInvalidatingInst - Return true if BB or any of the predecessors of BB
424// (until DestBB) contain a store (or other invalidating) instruction.
425//
426bool GCSE::CheckForInvalidatingInst(BasicBlock *BB, BasicBlock *DestBB,
427 set<BasicBlock*> &VisitedSet) {
428 // Found the termination point!
429 if (BB == DestBB || VisitedSet.count(BB)) return false;
430
431 // Avoid infinite recursion!
432 VisitedSet.insert(BB);
433
434 // Have we already checked this block?
435 map<BasicBlock*, bool>::iterator MI = BBContainsStore.find(BB);
436
437 if (MI != BBContainsStore.end()) {
438 // If this block is known to contain a store, exit the recursion early...
439 if (MI->second) return true;
440 // Otherwise continue checking predecessors...
441 } else {
442 // We don't know if this basic block contains an invalidating instruction.
443 // Check now:
444 bool HasStore = std::find_if(BB->begin(), BB->end(),
445 isInvalidatingInst) != BB->end();
446 if ((BBContainsStore[BB] = HasStore)) // Update map
447 return true; // Exit recursion early...
448 }
449
450 // Check all of our predecessor blocks...
451 for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI)
452 if (CheckForInvalidatingInst(*PI, DestBB, VisitedSet))
453 return true;
454
455 // None of our predecessor blocks contain a store, and we don't either!
456 return false;
457}