[polly] r267146 - Bail for complex execution contexts of invariant loads

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 04:41:15 PDT 2016


Author: jdoerfert
Date: Fri Apr 22 06:41:14 2016
New Revision: 267146

URL: http://llvm.org/viewvc/llvm-project?rev=267146&view=rev
Log:
Bail for complex execution contexts of invariant loads

Added:
    polly/trunk/test/ScopInfo/complex_execution_context.ll
Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/test/ScopInfo/long-sequence-of-error-blocks-2.ll

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=267146&r1=267145&r2=267146&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Apr 22 06:41:14 2016
@@ -3176,14 +3176,23 @@ void Scop::addInvariantLoads(ScopStmt &S
   if (InvMAs.empty())
     return;
 
+  auto *StmtInvalidCtx = Stmt.getInvalidContext();
+
   // Get the context under which the statement is executed but remove the error
   // context under which this statement is reached.
   isl_set *DomainCtx = isl_set_params(Stmt.getDomain());
-  DomainCtx = isl_set_subtract(DomainCtx, Stmt.getInvalidContext());
+  DomainCtx = isl_set_subtract(DomainCtx, StmtInvalidCtx);
   DomainCtx = isl_set_remove_redundancies(DomainCtx);
   DomainCtx = isl_set_detect_equalities(DomainCtx);
   DomainCtx = isl_set_coalesce(DomainCtx);
 
+  if (isl_set_n_basic_set(DomainCtx) >= MaxConjunctsInDomain) {
+    auto *AccInst = InvMAs.front()->getAccessInstruction();
+    invalidate(COMPLEXITY, AccInst->getDebugLoc());
+    isl_set_free(DomainCtx);
+    return;
+  }
+
   // Project out all parameters that relate to loads in the statement. Otherwise
   // we could have cyclic dependences on the constraints under which the
   // hoisted loads are executed and we could not determine an order in which to

Added: polly/trunk/test/ScopInfo/complex_execution_context.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/complex_execution_context.ll?rev=267146&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/complex_execution_context.ll (added)
+++ polly/trunk/test/ScopInfo/complex_execution_context.ll Fri Apr 22 06:41:14 2016
@@ -0,0 +1,47 @@
+; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops \
+; RUN:     < %s 2>&1 | FileCheck %s
+;
+; CHECK: Low complexity assumption:
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+ at board = external global [421 x i8], align 16
+
+; Function Attrs: nounwind uwtable
+define fastcc void @ping_recurse(i32* nocapture %mx, i32* nocapture %mr, i32 %color) unnamed_addr {
+entry:
+  br label %land.lhs.true38.1
+
+if.end58:                                         ; preds = %land.lhs.true38.2, %if.end54.1
+  ret void
+
+land.lhs.true38.1:                                ; preds = %entry
+  %arrayidx34.1 = getelementptr inbounds [421 x i8], [421 x i8]* @board, i64 0, i64 0
+  %arrayidx40.1 = getelementptr inbounds i32, i32* %mr, i64 0
+  %0 = load i32, i32* %arrayidx40.1, align 4
+  %cmp41.1 = icmp eq i32 %0, 0
+  br i1 %cmp41.1, label %land.lhs.true43.1, label %if.end54.1
+
+land.lhs.true43.1:                                ; preds = %land.lhs.true38.1
+  %arrayidx45.1 = getelementptr inbounds i32, i32* %mx, i64 0
+  %1 = load i32, i32* %arrayidx45.1, align 4
+  %cmp46.1 = icmp eq i32 %1, 1
+  %cmp51.1 = icmp eq i32 0, %color
+  %or.cond.1 = or i1 %cmp51.1, %cmp46.1
+  br i1 %or.cond.1, label %if.then53.1, label %if.end54.1
+
+if.then53.1:                                      ; preds = %land.lhs.true43.1
+  tail call fastcc void @ping_recurse(i32* nonnull %mx, i32* nonnull %mr, i32 %color)
+  br label %if.end54.1
+
+if.end54.1:                                       ; preds = %if.then53.1, %land.lhs.true43.1, %land.lhs.true38.1
+  %arrayidx34.2 = getelementptr inbounds [421 x i8], [421 x i8]* @board, i64 0, i64 0
+  %2 = load i8, i8* %arrayidx34.2, align 1
+  %cmp36.2 = icmp eq i8 %2, 3
+  br i1 %cmp36.2, label %if.end58, label %land.lhs.true38.2
+
+land.lhs.true38.2:                                ; preds = %if.end54.1
+  %arrayidx40.2 = getelementptr inbounds i32, i32* %mr, i64 0
+  %3 = load i32, i32* %arrayidx40.2, align 4
+  br label %if.end58
+}

Modified: polly/trunk/test/ScopInfo/long-sequence-of-error-blocks-2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/long-sequence-of-error-blocks-2.ll?rev=267146&r1=267145&r2=267146&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/long-sequence-of-error-blocks-2.ll (original)
+++ polly/trunk/test/ScopInfo/long-sequence-of-error-blocks-2.ll Fri Apr 22 06:41:14 2016
@@ -5,14 +5,8 @@ target triple = "x86_64-unknown-linux-gn
 
 %struct.hoge = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [8 x [2 x i32]], [8 x [2 x i32]], [4 x [4 x i32]], i32, i32, i32, i32, [256 x i8], [256 x i8], [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, [500 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [1024 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], [256 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [256 x i8], i32, i32, i32*, i32*, i8*, i32*, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, double, [5
  x double], i32, [8 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [6 x double], [6 x double], [256 x i8], i32, i32, i32, i32, [2 x [5 x i32]], [2 x [5 x i32]], i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i32 }
 
-; The assumed context of this test case has at some point become very complex.
-; However, since we keep both the assumed as well as invalid context that
-; problem is solved.
-;
-; CHECK:      Assumed Context:
-; CHECK-NEXT:   [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> {  :  }
-; CHECK:      Invalid Context:
-; CHECK-NEXT:   [tmp17, tmp21, tmp27, tmp31, tmp37, tmp41, tmp46, tmp52, tmp56, tmp62] -> { : (tmp37 < 0 and tmp41 < 0 and tmp46 > 0) or (tmp17 < 0 and tmp21 < 0) or (tmp17 < 0 and tmp21 > 0) or (tmp17 > 0 and tmp21 < 0) or (tmp17 > 0 and tmp21 > 0) or (tmp37 < 0 and tmp41 > 0 and tmp46 > 0) or (tmp37 > 0 and tmp41 < 0 and tmp46 > 0) or (tmp37 > 0 and tmp41 > 0 and tmp46 > 0) or (tmp27 = 3 and tmp31 <= 143) or (tmp56 = 0 and tmp52 < 0) or (tmp56 = 0 and tmp52 > 0) }
+; The execution context of invalid loads in this test case has at some point become very complex and we should bail.
+; CHECK-NOT: Statements
 
 @global = external global [300 x i8], align 16
 @global1 = external global %struct.hoge*, align 8




More information about the llvm-commits mailing list