[polly] r258803 - [FIX] Domain generation error due to loops in non-affine regions

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 26 03:03:25 PST 2016


Author: jdoerfert
Date: Tue Jan 26 05:03:25 2016
New Revision: 258803

URL: http://llvm.org/viewvc/llvm-project?rev=258803&view=rev
Log:
[FIX] Domain generation error due to loops in non-affine regions


Added:
    polly/trunk/test/ScopInfo/non-affine-region-with-loop-2.ll
Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=258803&r1=258802&r2=258803&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Jan 26 05:03:25 2016
@@ -2071,7 +2071,7 @@ void Scop::buildDomains(Region *R) {
 }
 
 void Scop::buildDomainsWithBranchConstraints(Region *R) {
-  RegionInfo &RI = *R->getRegionInfo();
+  auto &BoxedLoops = *SD.getBoxedLoops(&getRegion());
 
   // To create the domain for each block in R we iterate over all blocks and
   // subregions in R and propagate the conditions under which the current region
@@ -2146,10 +2146,8 @@ void Scop::buildDomainsWithBranchConstra
       // Do not adjust the number of dimensions if we enter a boxed loop or are
       // in a non-affine subregion or if the surrounding loop stays the same.
       Loop *SuccBBLoop = LI.getLoopFor(SuccBB);
-      Region *SuccRegion = RI.getRegionFor(SuccBB);
-      if (SD.isNonAffineSubRegion(SuccRegion, &getRegion()))
-        while (SuccBBLoop && SuccRegion->contains(SuccBBLoop))
-          SuccBBLoop = SuccBBLoop->getParentLoop();
+      while (BoxedLoops.count(SuccBBLoop))
+        SuccBBLoop = SuccBBLoop->getParentLoop();
 
       if (BBLoop != SuccBBLoop) {
 

Added: polly/trunk/test/ScopInfo/non-affine-region-with-loop-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/non-affine-region-with-loop-2.ll?rev=258803&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/non-affine-region-with-loop-2.ll (added)
+++ polly/trunk/test/ScopInfo/non-affine-region-with-loop-2.ll Tue Jan 26 05:03:25 2016
@@ -0,0 +1,55 @@
+; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-scops -analyze < %s | FileCheck %s
+; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-codegen -analyze
+;
+; CHECK:    Stmt_loop3
+; CHECK:            Domain :=
+; CHECK:                [indvar] -> { Stmt_loop3[0] : indvar >= 101 or indvar <= 99 };
+; CHECK:            Schedule :=
+; CHECK:                [indvar] -> { Stmt_loop3[i0] -> [0, 0] : indvar >= 101 or indvar <= 99 };
+; CHECK:    Stmt_loop2__TO__loop
+; CHECK:            Domain :=
+; CHECK:                [indvar] -> { Stmt_loop2__TO__loop[] : indvar <= 99 or indvar >= 101 };
+; CHECK:            Schedule :=
+; CHECK:                [indvar] -> { Stmt_loop2__TO__loop[] -> [1, 0] : indvar >= 101 or indvar <= 99 };
+;
+define void @foo(i64* %A, i64 %p) {
+entry:
+  br label %loop
+
+loop:
+  %indvar.3 = phi i64 [0, %entry], [%indvar.3, %loop], [%indvar.next.3, %next2], [%indvar.next.3, %cond]
+  %indvar = phi i64 [0, %entry], [%indvar.next, %loop], [0, %next2], [0, %cond]
+  %indvar.next = add i64 %indvar, 1
+  fence seq_cst
+  %cmp = icmp eq i64 %indvar, 100
+  br i1 %cmp, label %next, label %loop
+
+next:
+  %indvar.next.3 = add i64 %indvar.3, 1
+  %cmp.3 = icmp eq i64 %indvar, 100
+  br i1 %cmp.3, label %loop3, label %exit
+
+loop3:
+  %indvar.6 = phi i64 [0, %next], [%indvar.next.6, %loop3]
+  %indvar.next.6 = add i64 %indvar.6, 1
+  %cmp.6 = icmp eq i64 %indvar.6, 100
+  br i1 %cmp.3, label %loop3, label %loop2
+
+loop2:
+  %indvar.2 = phi i64 [0, %loop3], [%indvar.next.2, %loop2], [0, %cond]
+  %indvar.next.2 = add i64 %indvar.2, 1
+  %prod = mul i64 %indvar.2, %indvar.2
+  store i64 %indvar, i64* %A
+  %cmp.2 = icmp eq i64 %prod, 100
+  br i1 %cmp.2, label %loop2, label %next2
+
+next2:
+  %cmp.4 = icmp eq i64 %p, 100
+  br i1 %cmp.4, label %loop, label %cond
+
+cond:
+  br i1 false, label %loop, label %loop2
+
+exit:
+  ret void
+}




More information about the llvm-commits mailing list