Index: polly/trunk/lib/Support/VirtualInstruction.cpp =================================================================== --- polly/trunk/lib/Support/VirtualInstruction.cpp +++ polly/trunk/lib/Support/VirtualInstruction.cpp @@ -21,7 +21,12 @@ VirtualUse VirtualUse ::create(Scop *S, const Use &U, LoopInfo *LI, bool Virtual) { auto *UserBB = getUseBlock(U); - auto *UserStmt = S->getStmtFor(UserBB); + Instruction *UI = dyn_cast(U.getUser()); + ScopStmt *UserStmt = nullptr; + if (PHINode *PHI = dyn_cast(UI)) + UserStmt = S->getLastStmtFor(PHI->getIncomingBlock(U)); + else + UserStmt = S->getStmtFor(UI); auto *UserScope = LI->getLoopFor(UserBB); return create(S, UserStmt, UserScope, U.get(), Virtual); }