[polly] r182661 - independent blocks: do not insert stores between phi nodes
Sebastian Pop
spop at codeaurora.org
Fri May 24 11:45:58 PDT 2013
Author: spop
Date: Fri May 24 13:45:58 2013
New Revision: 182661
URL: http://llvm.org/viewvc/llvm-project?rev=182661&view=rev
Log:
independent blocks: do not insert stores between phi nodes
Modified:
polly/trunk/lib/IndependentBlocks.cpp
Modified: polly/trunk/lib/IndependentBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/IndependentBlocks.cpp?rev=182661&r1=182660&r2=182661&view=diff
==============================================================================
--- polly/trunk/lib/IndependentBlocks.cpp (original)
+++ polly/trunk/lib/IndependentBlocks.cpp Fri May 24 13:45:58 2013
@@ -394,9 +394,16 @@ bool IndependentBlocks::translateScalarT
AllocaInst *Slot = new AllocaInst(
Inst->getType(), 0, Inst->getName() + ".s2a", AllocaBlock->begin());
assert(!isa<InvokeInst>(Inst) && "Unexpect Invoke in Scop!");
- // Store right after Inst.
- BasicBlock::iterator StorePos = Inst;
- (void) new StoreInst(Inst, Slot, ++StorePos);
+
+ // Store right after Inst, and make sure the position is after all phi nodes.
+ BasicBlock::iterator StorePos;
+ if (isa<PHINode>(Inst)) {
+ StorePos = Inst->getParent()->getFirstNonPHI();
+ } else {
+ StorePos = Inst;
+ StorePos++;
+ }
+ (void) new StoreInst(Inst, Slot, StorePos);
if (!LoadOutside.empty()) {
LoadInst *ExitLoad = new LoadInst(Slot, Inst->getName() + ".loadoutside",
More information about the llvm-commits
mailing list