diff options
| -rw-r--r-- | polly/lib/Analysis/ScopDetection.cpp | 29 | ||||
| -rw-r--r-- | polly/test/ScopDetect/dependency_to_phi_node_outside_of_region.ll | 34 |
2 files changed, 34 insertions, 29 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 3834c06213a..62313566c0b 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -142,7 +142,6 @@ BADSCOP_STAT(IndEdge, "Found invalid region entering edges"); BADSCOP_STAT(LoopBound, "Loop bounds can not be computed"); BADSCOP_STAT(FuncCall, "Function call with side effects appeared"); BADSCOP_STAT(AffFunc, "Expression not affine"); -BADSCOP_STAT(Scalar, "Found scalar dependency"); BADSCOP_STAT(Alias, "Found base address alias"); BADSCOP_STAT(SimpleLoop, "Loop not in -loop-simplify form"); BADSCOP_STAT(Other, "Others"); @@ -329,30 +328,6 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst, return true; } -bool ScopDetection::hasScalarDependency(Instruction &Inst, - Region &RefRegion) const { - for (Instruction::use_iterator UI = Inst.use_begin(), UE = Inst.use_end(); - UI != UE; ++UI) - if (Instruction *Use = dyn_cast<Instruction>(*UI)) - if (!RefRegion.contains(Use->getParent())) { - // DirtyHack 1: PHINode user outside the Scop is not allow, if this - // PHINode is induction variable, the scalar to array transform may - // break it and introduce a non-indvar PHINode, which is not allow in - // Scop. - // This can be fix by: - // Introduce a IndependentBlockPrepare pass, which translate all - // PHINodes not in Scop to array. - // The IndependentBlockPrepare pass can also split the entry block of - // the function to hold the alloca instruction created by scalar to - // array. and split the exit block of the Scop so the new create load - // instruction for escape users will not break other Scops. - if (isa<PHINode>(Use)) - return true; - } - - return false; -} - bool ScopDetection::isValidInstruction(Instruction &Inst, DetectionContext &Context) const { if (PHINode *PN = dyn_cast<PHINode>(&Inst)) @@ -364,10 +339,6 @@ bool ScopDetection::isValidInstruction(Instruction &Inst, INVALID(IndVar, "Non canonical PHI node: " << Inst); } - // Scalar dependencies are not allowed. - if (hasScalarDependency(Inst, Context.CurRegion)) - INVALID(Scalar, "Scalar dependency found: " << Inst); - // We only check the call instruction but not invoke instruction. if (CallInst *CI = dyn_cast<CallInst>(&Inst)) { if (isValidCallInst(*CI)) diff --git a/polly/test/ScopDetect/dependency_to_phi_node_outside_of_region.ll b/polly/test/ScopDetect/dependency_to_phi_node_outside_of_region.ll new file mode 100644 index 00000000000..2a67dd6a70b --- /dev/null +++ b/polly/test/ScopDetect/dependency_to_phi_node_outside_of_region.ll @@ -0,0 +1,34 @@ +; RUN: opt %loadPolly -polly-detect < %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" + +define void @f(i64* %A, i64 %N, i64 %M) nounwind { +entry: + fence seq_cst + br label %for.i + +for.i: + %indvar = phi i64 [ 0, %entry ], [ %indvar.next, %for.i ] + %scevgep = getelementptr i64* %A, i64 %indvar + store i64 %indvar, i64* %scevgep + %indvar.next = add nsw i64 %indvar, 1 + %exitcond = icmp eq i64 %indvar.next, %N + br i1 %exitcond, label %next, label %for.i + +next: + fence seq_cst + br label %for.j + +for.j: + %indvar.j = phi i64 [ %indvar, %next ], [ %indvar.j.next, %for.j ] + %scevgep.j = getelementptr i64* %A, i64 %indvar.j + store i64 %indvar.j, i64* %scevgep.j + fence seq_cst + %indvar.j.next = add nsw i64 %indvar.j, 1 + %exitcond.j = icmp eq i64 %indvar.j.next, %M + br i1 %exitcond.j, label %return, label %for.j + +return: + fence seq_cst + ret void +} |

