[polly] r329214 - [Polly][IslAst] Fix minimal dependence distance.
Huihui Zhang via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 11:08:13 PDT 2018
Author: huihuiz
Date: Wed Apr 4 11:08:13 2018
New Revision: 329214
URL: http://llvm.org/viewvc/llvm-project?rev=329214&view=rev
Log:
[Polly][IslAst] Fix minimal dependence distance.
Summary:
When checking the parallelism of a scheduling dimension, we first check if excluding reduction dependences the loop is parallel or not.
If the loop is not parallel, then we need to return the minimal dependence distance of all data dependences, including the previously subtracted reduction dependences.
Reviewers: grosser, Meinersbur, efriedma, eli.friedman, jdoerfert, bollu
Reviewed By: Meinersbur
Subscribers: llvm-commits, pollydev
Tags: #polly
Differential Revision: https://reviews.llvm.org/D45236
Added:
polly/trunk/test/Isl/Ast/dependence_distance_minimal.ll
Modified:
polly/trunk/lib/Analysis/DependenceInfo.cpp
polly/trunk/lib/CodeGen/IslAst.cpp
Modified: polly/trunk/lib/Analysis/DependenceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/DependenceInfo.cpp?rev=329214&r1=329213&r2=329214&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/DependenceInfo.cpp (original)
+++ polly/trunk/lib/Analysis/DependenceInfo.cpp Wed Apr 4 11:08:13 2018
@@ -646,7 +646,8 @@ void Dependences::calculateDependences(S
// Step 4)
addPrivatizationDependences();
- }
+ } else
+ TC_RED = isl_union_map_empty(isl_union_map_get_space(RED));
DEBUG({
dbgs() << "Final Wrapped Dependences:\n";
Modified: polly/trunk/lib/CodeGen/IslAst.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslAst.cpp?rev=329214&r1=329213&r2=329214&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslAst.cpp (original)
+++ polly/trunk/lib/CodeGen/IslAst.cpp Wed Apr 4 11:08:13 2018
@@ -219,9 +219,14 @@ static bool astScheduleDimIsParallel(__i
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))
Added: polly/trunk/test/Isl/Ast/dependence_distance_minimal.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/Ast/dependence_distance_minimal.ll?rev=329214&view=auto
==============================================================================
--- polly/trunk/test/Isl/Ast/dependence_distance_minimal.ll (added)
+++ polly/trunk/test/Isl/Ast/dependence_distance_minimal.ll Wed Apr 4 11:08:13 2018
@@ -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: Stmt_bb9(c0, c1);
+; CHECK: Stmt_bb9_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"
+
+define void @foo(i32* nocapture %arg, i32* nocapture %arg1) {
+bb:
+ br label %bb2
+
+bb2: ; preds = %bb
+ br label %bb4
+
+bb3: ; preds = %bb6
+ ret void
+
+bb4: ; preds = %bb6, %bb2
+ %tmp = phi i32 [ 0, %bb2 ], [ %tmp7, %bb6 ]
+ %tmp5 = getelementptr inbounds i32, i32* %arg1, i32 %tmp
+ br label %bb9
+
+bb6: ; preds = %bb9
+ %tmp7 = add nuw nsw i32 %tmp, 1
+ %tmp8 = icmp eq i32 %tmp7, 500
+ br i1 %tmp8, label %bb3, label %bb4
+
+bb9: ; preds = %bb9, %bb4
+ %tmp10 = phi i32 [ 1, %bb4 ], [ %tmp19, %bb9 ]
+ %tmp11 = load i32, i32* %tmp5, align 4
+ %tmp12 = add nsw i32 %tmp11, 1
+ store i32 %tmp12, i32* %tmp5, align 4
+ %tmp13 = urem i32 %tmp10, 250
+ %tmp14 = getelementptr inbounds i32, i32* %arg, i32 %tmp13
+ %tmp15 = load i32, i32* %tmp14, align 4
+ %tmp16 = getelementptr inbounds i32, i32* %arg, i32 %tmp10
+ %tmp17 = load i32, i32* %tmp16, align 4
+ %tmp18 = add nsw i32 %tmp17, %tmp15
+ store i32 %tmp18, i32* %tmp16, align 4
+ %tmp19 = add nuw nsw i32 %tmp10, 1
+ %tmp20 = icmp eq i32 %tmp19, 1000
+ br i1 %tmp20, label %bb6, label %bb9
+}
More information about the llvm-commits
mailing list