[polly] r252860 - RegionGenerator: Only introduce subregion.ivs for loops fully within a subregion

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 23:34:10 PST 2015


Author: grosser
Date: Thu Nov 12 01:34:09 2015
New Revision: 252860

URL: http://llvm.org/viewvc/llvm-project?rev=252860&view=rev
Log:
RegionGenerator: Only introduce subregion.ivs for loops fully within a subregion

IVs of loops for which the loop header is in the subregion, but not the entire
loop may be incremented outside of the subregion and can consequently not be
kept private to the subregion. Instead, they need to and are modeled as virtual
loops in the iteration domains. As this is the case, generating new subregion
induction variables for such loops is not needed and indeed wrong as they would
hide the virtual induction variables modeled in the scop.

This fixes a miscompile in MultiSource/Benchmarks/Ptrdist/bc and
MultiSource/Benchmarks/nbench/. Thanks Michael and Johannes for their
investiagations and helpful observations regarding this bug.

Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll
    polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=252860&r1=252859&r2=252860&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Thu Nov 12 01:34:09 2015
@@ -1141,7 +1141,7 @@ void RegionGenerator::copyStmt(ScopStmt
   // replacement for SCEVs refering to the old loop.
   for (BasicBlock *BB : SeenBlocks) {
     Loop *L = LI.getLoopFor(BB);
-    if (L == nullptr || L->getHeader() != BB)
+    if (L == nullptr || L->getHeader() != BB || !R->contains(L))
       continue;
 
     BasicBlock *BBCopy = BlockMap[BB];

Modified: polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll?rev=252860&r1=252859&r2=252860&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll (original)
+++ polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-3.ll Thu Nov 12 01:34:09 2015
@@ -13,11 +13,9 @@ loop:
   br i1 %cond0, label %branch1, label %backedge
 
 ; CHECK-LABEL: polly.stmt.loop:
-; CHECK-NEXT: %polly.subregion.iv = phi i32 [ 0, %polly.stmt.loop.entry ]
 ; CHECK-NEXT: %p_val0 = fadd float 1.000000e+00, 2.000000e+00
 ; CHECK-NEXT: %p_val1 = fadd float 1.000000e+00, 2.000000e+00
 ; CHECK-NEXT: %p_val2 = fadd float 1.000000e+00, 2.000000e+00
-; CHECK-NEXT: %polly.subregion.iv.inc = add i32 %polly.subregion.iv, 1
 ; CHECK-NEXT: store float %p_val0, float* %merge.phiops
 ; CHECK-NEXT: br i1
 

Modified: polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll?rev=252860&r1=252859&r2=252860&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll (original)
+++ polly/trunk/test/Isl/CodeGen/non-affine-phi-node-expansion-4.ll Thu Nov 12 01:34:09 2015
@@ -12,10 +12,8 @@ loop:
   br i1 %cond0, label %branch1, label %backedge
 
 ; CHECK-LABEL: polly.stmt.loop:
-; CHECK-NEXT:    %polly.subregion.iv = phi i32 [ 0, %polly.stmt.loop.entry ]
 ; CHECK-NEXT:    %p_val0 = fadd float 1.000000e+00, 2.000000e+00
 ; CHECK-NEXT:    %p_val1 = fadd float 1.000000e+00, 2.000000e+00
-; CHECK-NEXT:    %polly.subregion.iv.inc = add i32 %polly.subregion.iv, 1
 ; CHECK-NEXT:    store float %p_val0, float* %merge.phiops
 ; CHECK-NEXT:    br i1
 




More information about the llvm-commits mailing list