[polly] r184128 - revert r183799: scop detection: remove an iteration over all uses
Sebastian Pop
spop at codeaurora.org
Mon Jun 17 14:43:10 PDT 2013
Author: spop
Date: Mon Jun 17 16:43:10 2013
New Revision: 184128
URL: http://llvm.org/viewvc/llvm-project?rev=184128&view=rev
Log:
revert r183799: scop detection: remove an iteration over all uses
Modified:
polly/trunk/lib/Analysis/ScopDetection.cpp
Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=184128&r1=184127&r2=184128&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Jun 17 16:43:10 2013
@@ -142,6 +142,7 @@ BADSCOP_STAT(IndEdge, "Found invalid reg
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");
@@ -326,6 +327,30 @@ bool ScopDetection::isValidMemoryAccess(
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))
@@ -337,6 +362,10 @@ bool ScopDetection::isValidInstruction(I
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))
More information about the llvm-commits
mailing list