Index: lib/Analysis/DependenceInfo.cpp =================================================================== --- lib/Analysis/DependenceInfo.cpp +++ lib/Analysis/DependenceInfo.cpp @@ -646,7 +646,8 @@ // Step 4) addPrivatizationDependences(); - } + } else + TC_RED = isl_union_map_empty(isl_union_map_get_space(RED)); DEBUG({ dbgs() << "Final Wrapped Dependences:\n"; Index: lib/CodeGen/IslAst.cpp =================================================================== --- lib/CodeGen/IslAst.cpp +++ lib/CodeGen/IslAst.cpp @@ -219,9 +219,14 @@ isl_union_map *Deps = D->getDependences( Dependences::TYPE_RAW | Dependences::TYPE_WAW | Dependences::TYPE_WAR); - if (!D->isParallel(Schedule, Deps, &NodeInfo->MinimalDependenceDistance) && - !isl_union_map_free(Schedule)) + if (!D->isParallel(Schedule, Deps)) { + isl_union_map *DepsAll = + D->getDependences(Dependences::TYPE_RAW | Dependences::TYPE_WAW | + Dependences::TYPE_WAR | Dependences::TYPE_TC_RED); + D->isParallel(Schedule, DepsAll, &NodeInfo->MinimalDependenceDistance); + isl_union_map_free(Schedule); return false; + } isl_union_map *RedDeps = D->getDependences(Dependences::TYPE_TC_RED); if (!D->isParallel(Schedule, RedDeps)) Index: test/Isl/Ast/dependence_distance_minimal.ll =================================================================== --- /dev/null +++ test/Isl/Ast/dependence_distance_minimal.ll @@ -0,0 +1,57 @@ +; RUN: opt %loadPolly -polly-ast -polly-ast-detect-parallel -analyze < %s | FileCheck %s +; +; The minimal dependence distance of the innermost loop should be 1 instead of 250. +; CHECK: #pragma minimal dependence distance: 1 +; CHECK: for (int c0 = 0; c0 <= 499; c0 += 1) +; CHECK: #pragma minimal dependence distance: 1 +; CHECK: for (int c1 = 0; c1 <= 998; c1 += 1) +; CHECK: Stmt1(c0, c1); +; CHECK: Stmt1_b(c0, c1); +; +; void foo (int *A, int *B) { +; for (int i=0; i < 500; i++) { +; for (int j=0; j < 1000; j++) { +; B[i] = B[i] + 1; +; A[j] += A[j % 250]; +; } +; } +; } +; +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" + +; Function Attrs: norecurse nounwind +define void @foo(i32* nocapture, i32* nocapture) { + br label %3 + +;