aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2013-06-06 02:48:37 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2013-06-06 02:48:37 +0000
commit33a10126442b036ef21f15d47bf4d05ba0066f4d (patch)
tree4fb3c68a82b9324f4c1c91aed63720c27e86d02b
parent03aef0969e34e6d8c704b5b59aae0226ed5d1891 (diff)
downloadllvm-33a10126442b036ef21f15d47bf4d05ba0066f4d.zip
llvm-33a10126442b036ef21f15d47bf4d05ba0066f4d.tar.gz
llvm-33a10126442b036ef21f15d47bf4d05ba0066f4d.tar.bz2
independent blocks: do not insert stores between phi nodes
Merged from: https://llvm.org/svn/llvm-project/polly/trunk@182661 llvm-svn: 183380
-rw-r--r--polly/lib/IndependentBlocks.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/polly/lib/IndependentBlocks.cpp b/polly/lib/IndependentBlocks.cpp
index 69d7942..cb636486 100644
--- a/polly/lib/IndependentBlocks.cpp
+++ b/polly/lib/IndependentBlocks.cpp
@@ -394,9 +394,16 @@ bool IndependentBlocks::translateScalarToArray(Instruction *Inst,
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",