[polly] r243849 - Dependences: Zero pad the schedule map
Tobias Grosser
tobias at grosser.es
Sun Aug 2 06:30:34 PDT 2015
Author: grosser
Date: Sun Aug 2 08:30:33 2015
New Revision: 243849
URL: http://llvm.org/viewvc/llvm-project?rev=243849&view=rev
Log:
Dependences: Zero pad the schedule map
The schedule map we derive from a schedule tree map may map statements into
schedule spaces of different dimensionality. This change adds zero padding
to ensure just a single schedule space is used and the translation from
a union_map to an isl_multi_union_pw_aff does not fail.
Added:
polly/trunk/test/DependenceInfo/different_schedule_dimensions.ll
Modified:
polly/trunk/lib/Analysis/DependenceInfo.cpp
Modified: polly/trunk/lib/Analysis/DependenceInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/DependenceInfo.cpp?rev=243849&r1=243848&r2=243849&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/DependenceInfo.cpp (original)
+++ polly/trunk/lib/Analysis/DependenceInfo.cpp Sun Aug 2 08:30:33 2015
@@ -219,6 +219,34 @@ void Dependences::addPrivatizationDepend
isl_union_set_free(Universe);
}
+static isl_stat getMaxScheduleDim(__isl_take isl_map *Map, void *User) {
+ unsigned int *MaxScheduleDim = (unsigned int *)User;
+ *MaxScheduleDim = std::max(*MaxScheduleDim, isl_map_dim(Map, isl_dim_out));
+ isl_map_free(Map);
+ return isl_stat_ok;
+}
+
+__isl_give isl_union_map *
+addZeroPaddingToSchedule(__isl_take isl_union_map *Schedule) {
+ unsigned int MaxScheduleDim = 0;
+
+ isl_union_map_foreach_map(Schedule, getMaxScheduleDim, &MaxScheduleDim);
+
+ auto ExtensionMap = isl_union_map_empty(isl_union_map_get_space(Schedule));
+ for (unsigned int i = 0; i <= MaxScheduleDim; i++) {
+ auto *Map = isl_map_identity(
+ isl_space_alloc(isl_union_map_get_ctx(Schedule), 0, i, i));
+ Map = isl_map_add_dims(Map, isl_dim_out, MaxScheduleDim - i);
+ for (unsigned int j = 0; j < MaxScheduleDim - i; j++)
+ Map = isl_map_fix_si(Map, isl_dim_out, i + j, 0);
+
+ ExtensionMap = isl_union_map_add_map(ExtensionMap, Map);
+ }
+ Schedule = isl_union_map_apply_range(Schedule, ExtensionMap);
+
+ return Schedule;
+}
+
void Dependences::calculateDependences(Scop &S) {
isl_union_map *Read, *Write, *MayWrite, *AccessSchedule, *StmtSchedule;
isl_schedule *Schedule;
@@ -239,11 +267,13 @@ void Dependences::calculateDependences(S
isl_union_map_union(AccessSchedule, isl_union_map_copy(StmtSchedule));
Schedule = isl_schedule_from_domain(
isl_union_map_domain(isl_union_map_copy(ScheduleMap)));
- if (!isl_union_map_is_empty(ScheduleMap))
+ if (!isl_union_map_is_empty(ScheduleMap)) {
+ ScheduleMap = addZeroPaddingToSchedule(ScheduleMap);
Schedule = isl_schedule_insert_partial_schedule(
Schedule, isl_multi_union_pw_aff_from_union_map(ScheduleMap));
- else
+ } else {
isl_union_map_free(ScheduleMap);
+ }
}
Read = isl_union_map_coalesce(Read);
Added: polly/trunk/test/DependenceInfo/different_schedule_dimensions.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/DependenceInfo/different_schedule_dimensions.ll?rev=243849&view=auto
==============================================================================
--- polly/trunk/test/DependenceInfo/different_schedule_dimensions.ll (added)
+++ polly/trunk/test/DependenceInfo/different_schedule_dimensions.ll Sun Aug 2 08:30:33 2015
@@ -0,0 +1,48 @@
+; RUN: opt -S %loadPolly -polly-dependences -analyze < %s | FileCheck %s
+
+; CHECK: RAW dependences:
+; CHECK: { Stmt_bb9[0] -> Stmt_bb10[0] }
+; CHECK: WAR dependences:
+; CHECK: { Stmt_bb3[0] -> Stmt_bb10[0] }
+; CHECK: WAW dependences:
+; CHECK: { }
+; CHECK: Reduction dependences:
+; CHECK: { }
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+define void @hoge(i32 %arg, [1024 x double]* %arg1) {
+bb:
+ br label %bb2
+
+bb2: ; preds = %bb
+ br label %bb3
+
+bb3: ; preds = %bb10, %bb2
+ %tmp = phi i64 [ 0, %bb10 ], [ 0, %bb2 ]
+ %tmp4 = icmp sgt i32 %arg, 0
+ %tmp5 = getelementptr inbounds [1024 x double], [1024 x double]* %arg1, i64 0, i64 0
+ %tmp6 = load double, double* %tmp5, align 8
+ %tmp7 = fadd double undef, %tmp6
+ br i1 false, label %bb8, label %bb9
+
+bb8: ; preds = %bb3
+ br label %bb10
+
+bb9: ; preds = %bb3
+ br label %bb10
+
+bb10: ; preds = %bb9, %bb8
+ %tmp11 = phi double [ undef, %bb8 ], [ undef, %bb9 ]
+ %tmp12 = getelementptr inbounds [1024 x double], [1024 x double]* %arg1, i64 %tmp, i64 0
+ store double %tmp11, double* %tmp12, align 8
+ %tmp13 = add nuw nsw i64 0, 1
+ %tmp14 = trunc i64 %tmp13 to i32
+ br i1 false, label %bb3, label %bb15
+
+bb15: ; preds = %bb10
+ br label %bb16
+
+bb16: ; preds = %bb15
+ ret void
+}
More information about the llvm-commits
mailing list