File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
llvm/lib/Transforms/Scalar Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -337,9 +337,18 @@ bool LICM::canSinkOrHoistInst(Instruction &I) {
337
337
// / exit blocks of the loop.
338
338
// /
339
339
bool LICM::isNotUsedInLoop (Instruction &I) {
340
- for (Value::use_iterator UI = I.use_begin (), E = I.use_end (); UI != E; ++UI)
341
- if (CurLoop->contains (cast<Instruction>(*UI)->getParent ()))
340
+ for (Value::use_iterator UI = I.use_begin (), E = I.use_end (); UI != E; ++UI) {
341
+ Instruction *User = cast<Instruction>(*UI);
342
+ if (PHINode *PN = dyn_cast<PHINode>(User)) {
343
+ // PHI node uses occur in predecessor blocks!
344
+ for (unsigned i = 0 , e = PN->getNumIncomingValues (); i != e; ++i)
345
+ if (PN->getIncomingValue (i) == &I)
346
+ if (CurLoop->contains (PN->getIncomingBlock (i)))
347
+ return false ;
348
+ } else if (CurLoop->contains (User->getParent ())) {
342
349
return false ;
350
+ }
351
+ }
343
352
return true ;
344
353
}
345
354
You can’t perform that action at this time.
0 commit comments