[polly] r204470 - Return conservative result in case the dependence check timed out

Tobias Grosser tobias at grosser.es
Fri Mar 21 08:12:09 PDT 2014


Author: grosser
Date: Fri Mar 21 10:12:09 2014
New Revision: 204470

URL: http://llvm.org/viewvc/llvm-project?rev=204470&view=rev
Log:
Return conservative result in case the dependence check timed out

For complex examples it may happen that we do not compute dependences. In this
case we do not want to crash, but just not detect parallel loops.

Added:
    polly/trunk/test/Isl/Ast/OpenMP/single_loop_param_parallel_computeout.ll
Modified:
    polly/trunk/lib/Analysis/Dependences.cpp
    polly/trunk/lib/CodeGen/IslAst.cpp

Modified: polly/trunk/lib/Analysis/Dependences.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=204470&r1=204469&r2=204470&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/Dependences.cpp (original)
+++ polly/trunk/lib/Analysis/Dependences.cpp Fri Mar 21 10:12:09 2014
@@ -257,6 +257,11 @@ bool Dependences::isParallelDimension(__
   isl_map *ScheduleDeps;
   Scop *S = &getCurScop();
 
+  if (!hasValidDependences()) {
+    isl_set_free(ScheduleSubset);
+    return false;
+  }
+
   Deps = getDependences(TYPE_ALL);
 
   if (isl_union_map_is_empty(Deps)) {

Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=204470&r1=204469&r2=204470&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Fri Mar 21 10:12:09 2014
@@ -157,6 +157,10 @@ static bool astScheduleDimIsParallel(__i
   isl_space *ScheduleSpace;
   unsigned Dimension, IsParallel;
 
+  if (!D->hasValidDependences()) {
+    return false;
+  }
+
   Schedule = isl_ast_build_get_schedule(Build);
   ScheduleSpace = isl_ast_build_get_schedule_space(Build);
 
@@ -169,7 +173,7 @@ static bool astScheduleDimIsParallel(__i
   if (isl_union_map_is_empty(Deps)) {
     isl_union_map_free(Deps);
     isl_space_free(ScheduleSpace);
-    return 1;
+    return true;
   }
 
   ScheduleDeps = isl_map_from_union_map(Deps);

Added: polly/trunk/test/Isl/Ast/OpenMP/single_loop_param_parallel_computeout.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/OpenMP/single_loop_param_parallel_computeout.ll?rev=204470&view=auto
==============================================================================
--- polly/trunk/test/Isl/Ast/OpenMP/single_loop_param_parallel_computeout.ll (added)
+++ polly/trunk/test/Isl/Ast/OpenMP/single_loop_param_parallel_computeout.ll Fri Mar 21 10:12:09 2014
@@ -0,0 +1,36 @@
+; RUN: opt %loadPolly -polly-ast -polly-ast-detect-parallel -polly-dependences-computeout=1 -analyze < %s | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-pc-linux-gnu"
+
+; for (i = 0; i < n; i++)
+;   A[i] = 1;
+
+ at A = common global [1024 x i32] zeroinitializer
+define void @bar(i64 %n) {
+start:
+  fence seq_cst
+  br label %loop.header
+
+loop.header:
+  %i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
+  %scevgep = getelementptr [1024 x i32]* @A, i64 0, i64 %i
+  %exitcond = icmp ne i64 %i, %n
+  br i1 %exitcond, label %loop.body, label %ret
+
+loop.body:
+  store i32 1, i32* %scevgep
+  br label %loop.backedge
+
+loop.backedge:
+  %i.next = add nsw i64 %i, 1
+  br label %loop.header
+
+ret:
+  fence seq_cst
+  ret void
+}
+
+; CHECK-NOT: #pragma simd
+; CHECK-NOT: #pragma omp parallel for
+; CHECK: for (int c1 = 0; c1 < n; c1 += 1)
+; CHECK:   Stmt_loop_body(c1)





More information about the llvm-commits mailing list