[polly] r329655 - [CodeGen] Allow undefined loads in statement instances outside context.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 18:20:51 PDT 2018


Author: meinersbur
Date: Mon Apr  9 18:20:51 2018
New Revision: 329655

URL: http://llvm.org/viewvc/llvm-project?rev=329655&view=rev
Log:
[CodeGen] Allow undefined loads in statement instances outside context.

A check in assert-builds was meant to verify that a load provides a
value in all statement instances (i.e. its domain).  The domain is
commonly gist'ed within the parameter context to contain fewer
constraints.  However, statement instances outside the context are
no valid executions, hence the value provided can be undefined.

Refine the check for valid loads to only needed to be defined within
the SCoP context.

In addition, the JSONImporter had to be changed to allow importing
access relations that are broader than the current access relation,
but still defined over all statement instances.

This should fix the compiler crash in test-suite's oggenc of the
-polly-process-unprofitable buildbot.

Added:
    polly/trunk/test/Isl/CodeGen/load_subset_with_context.ll
    polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop
    polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop.transformed
Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/Exchange/JSONExporter.cpp

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=329655&r1=329654&r2=329655&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Mon Apr  9 18:20:51 2018
@@ -558,7 +558,8 @@ void BlockGenerator::generateScalarLoads
       continue;
 
 #ifndef NDEBUG
-    auto StmtDom = Stmt.getDomain();
+    auto StmtDom =
+        Stmt.getDomain().intersect_params(Stmt.getParent()->getContext());
     auto AccDom = MA->getAccessRelation().domain();
     assert(!StmtDom.is_subset(AccDom).is_false() &&
            "Scalar must be loaded in all statement instances");

Modified: polly/trunk/lib/Exchange/JSONExporter.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=329655&r1=329654&r2=329655&view=diff
==============================================================================
--- polly/trunk/lib/Exchange/JSONExporter.cpp (original)
+++ polly/trunk/lib/Exchange/JSONExporter.cpp Mon Apr  9 18:20:51 2018
@@ -512,6 +512,8 @@ importAccesses(Scop &S, Json::Value &JSc
           isl_set_intersect_params(NewAccessDomain, S.getContext().release());
       CurrentAccessDomain = isl_set_intersect_params(CurrentAccessDomain,
                                                      S.getContext().release());
+      CurrentAccessDomain =
+          isl_set_intersect(CurrentAccessDomain, Stmt.getDomain().release());
 
       if (MA->isRead() &&
           isl_set_is_subset(CurrentAccessDomain, NewAccessDomain) ==

Added: polly/trunk/test/Isl/CodeGen/load_subset_with_context.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/load_subset_with_context.ll?rev=329655&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/load_subset_with_context.ll (added)
+++ polly/trunk/test/Isl/CodeGen/load_subset_with_context.ll Mon Apr  9 18:20:51 2018
@@ -0,0 +1,57 @@
+; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-postfix=transformed -polly-codegen -S < %s | FileCheck %s
+;
+; A load must provide a value for every statement instance.
+; Statement instances not in the SCoP's context are irrelevant.
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+ at ATH = external dso_local unnamed_addr constant [88 x float], align 16
+
+define void @load_subset_with_context() {
+entry:
+  %ath = alloca [56 x float], align 16
+  br label %for.body
+
+for.cond176.preheader:                            ; preds = %for.cond33.preheader
+  ret void
+
+for.body:                                         ; preds = %for.cond33.preheader, %entry
+  %indvars.iv999 = phi i64 [ 0, %entry ], [ %indvars.iv.next1000, %for.cond33.preheader ]
+  %tmp5 = shl nsw i64 %indvars.iv999, 2
+  br label %for.cond7.preheader
+
+for.cond33.preheader:                             ; preds = %for.inc.3
+  %tmp175 = load float, float* undef, align 4
+  %indvars.iv.next1000 = add nuw nsw i64 %indvars.iv999, 1
+  %exitcond1002 = icmp eq i64 %indvars.iv.next1000, 17
+  br i1 %exitcond1002, label %for.cond176.preheader, label %for.body
+
+for.cond7.preheader:                              ; preds = %for.inc.3, %for.body
+  %indvars.iv958 = phi i64 [ 0, %for.body ], [ %indvars.iv.next959, %for.inc.3 ]
+  %tmp20 = add nuw nsw i64 %indvars.iv958, %tmp5
+  %arrayidx.2 = getelementptr inbounds [88 x float], [88 x float]* @ATH, i64 0, i64 0
+  %tmp157 = load float, float* %arrayidx.2, align 4
+  %tmp158 = add nuw nsw i64 %tmp20, 3
+  %cmp12.3 = icmp ult i64 %tmp158, 88
+  br i1 %cmp12.3, label %if.then.3, label %if.else.3
+
+if.else.3:                                        ; preds = %for.cond7.preheader
+  br label %for.inc.3
+
+if.then.3:                                        ; preds = %for.cond7.preheader
+  br label %for.inc.3
+
+for.inc.3:                                        ; preds = %if.then.3, %if.else.3
+  %min.1.3 = phi float [ undef, %if.then.3 ], [ %tmp157, %if.else.3 ]
+  %arrayidx29 = getelementptr inbounds [56 x float], [56 x float]* %ath, i64 0, i64 %indvars.iv958
+  store float %min.1.3, float* %arrayidx29, align 4
+  %indvars.iv.next959 = add nuw nsw i64 %indvars.iv958, 1
+  %exitcond961 = icmp eq i64 %indvars.iv.next959, 56
+  br i1 %exitcond961, label %for.cond33.preheader, label %for.cond7.preheader
+}
+
+
+; CHECK:      polly.stmt.if.else.3:
+; CHECK-NEXT:   %polly.access.cast.ath1 = bitcast [56 x float]* %ath to float*
+; CHECK-NEXT:   %polly.access.ath2 = getelementptr float, float* %polly.access.cast.ath1, i64 %polly.indvar
+; CHECK-NEXT:   %polly.access.ath2.reload = load float, float* %polly.access.ath2

Added: polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/load_subset_with_context___%25for.cond7.preheader---%25for.cond33.preheader.jscop?rev=329655&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop (added)
+++ polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop Mon Apr  9 18:20:51 2018
@@ -0,0 +1,74 @@
+{
+   "arrays" : [
+      {
+         "name" : "MemRef_ATH",
+         "sizes" : [ "*" ],
+         "type" : "float"
+      },
+      {
+         "name" : "MemRef_ath",
+         "sizes" : [ "*" ],
+         "type" : "float"
+      }
+   ],
+   "context" : "[p_0] -> {  : 0 <= p_0 <= 16 }",
+   "name" : "%for.cond7.preheader---%for.cond33.preheader",
+   "statements" : [
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_ATH[0] }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_tmp157[] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_for_cond7_preheader[i0] : 0 <= i0 <= 55 }",
+         "name" : "Stmt_for_cond7_preheader",
+         "schedule" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> [i0, 0] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_if_then_3[i0] -> MemRef_min_1_3__phi[] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_if_then_3[i0] : 0 <= i0 <= 84 - 4p_0 and i0 <= 55 }",
+         "name" : "Stmt_if_then_3",
+         "schedule" : "[p_0] -> { Stmt_if_then_3[i0] -> [i0, 2] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_if_else_3[i0] -> MemRef_tmp157[] }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_if_else_3[i0] -> MemRef_min_1_3__phi[] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_if_else_3[i0] : 85 - 4p_0 <= i0 <= 55 }",
+         "name" : "Stmt_if_else_3",
+         "schedule" : "[p_0] -> { Stmt_if_else_3[i0] -> [i0, 1] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_for_inc_3[i0] -> MemRef_min_1_3__phi[] }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_for_inc_3[i0] -> MemRef_ath[i0] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_for_inc_3[i0] : 0 <= i0 <= 55 }",
+         "name" : "Stmt_for_inc_3",
+         "schedule" : "[p_0] -> { Stmt_for_inc_3[i0] -> [i0, 3] }"
+      }
+   ]
+}

Added: polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop.transformed
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/load_subset_with_context___%25for.cond7.preheader---%25for.cond33.preheader.jscop.transformed?rev=329655&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop.transformed (added)
+++ polly/trunk/test/Isl/CodeGen/load_subset_with_context___%for.cond7.preheader---%for.cond33.preheader.jscop.transformed Mon Apr  9 18:20:51 2018
@@ -0,0 +1,74 @@
+{
+   "arrays" : [
+      {
+         "name" : "MemRef_ATH",
+         "sizes" : [ "*" ],
+         "type" : "float"
+      },
+      {
+         "name" : "MemRef_ath",
+         "sizes" : [ "*" ],
+         "type" : "float"
+      }
+   ],
+   "context" : "[p_0] -> {  : 0 <= p_0 <= 16 }",
+   "name" : "%for.cond7.preheader---%for.cond33.preheader",
+   "statements" : [
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_ATH[0] }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> MemRef_ath[i0] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_for_cond7_preheader[i0] : 0 <= i0 <= 55 }",
+         "name" : "Stmt_for_cond7_preheader",
+         "schedule" : "[p_0] -> { Stmt_for_cond7_preheader[i0] -> [i0, 0] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_if_then_3[i0] -> MemRef_ath[i0] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_if_then_3[i0] : 0 <= i0 <= 84 - 4p_0 and i0 <= 55 }",
+         "name" : "Stmt_if_then_3",
+         "schedule" : "[p_0] -> { Stmt_if_then_3[i0] -> [i0, 2] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_if_else_3[i0] -> MemRef_ath[i0] : i0 >= 0 }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_if_else_3[i0] -> MemRef_ath[i0] : i0 >= 0 }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_if_else_3[i0] : 85 - 4p_0 <= i0 <= 55 }",
+         "name" : "Stmt_if_else_3",
+         "schedule" : "[p_0] -> { Stmt_if_else_3[i0] -> [i0, 1] }"
+      },
+      {
+         "accesses" : [
+            {
+               "kind" : "read",
+               "relation" : "[p_0] -> { Stmt_for_inc_3[i0] -> MemRef_ath[i0] }"
+            },
+            {
+               "kind" : "write",
+               "relation" : "[p_0] -> { Stmt_for_inc_3[i0] -> MemRef_ath[i0] }"
+            }
+         ],
+         "domain" : "[p_0] -> { Stmt_for_inc_3[i0] : 0 <= i0 <= 55 }",
+         "name" : "Stmt_for_inc_3",
+         "schedule" : "[p_0] -> { Stmt_for_inc_3[i0] -> [i0, 3] }"
+      }
+   ]
+}




More information about the llvm-commits mailing list