[polly] r257170 - Call assumeNoOutOfBound only in updateDimensionality
Roman Gareev via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 06:02:01 PST 2016
Author: romangareev
Date: Fri Jan 8 08:01:59 2016
New Revision: 257170
URL: http://llvm.org/viewvc/llvm-project?rev=257170&view=rev
Log:
Call assumeNoOutOfBound only in updateDimensionality
Call assumeNoOutOfBound only in updateDimensionality to process situations
when new dimensions are added and new bounds checks are required.
Contributed-by: Tobias Grosser, Gareev Roman
Added:
polly/trunk/test/ScopInfo/process_added_dimensions.ll
Modified:
polly/trunk/lib/Analysis/ScopInfo.cpp
polly/trunk/test/ScopInfo/remarks.ll
polly/trunk/test/ScopInfo/user_provided_non_dominating_assumptions.ll
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=257170&r1=257169&r2=257170&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Fri Jan 8 08:01:59 2016
@@ -293,6 +293,8 @@ void MemoryAccess::updateDimensionality(
Map = isl_map_equate(Map, isl_dim_in, i - DimsMissing, isl_dim_out, i);
AccessRelation = isl_map_apply_range(AccessRelation, Map);
+
+ assumeNoOutOfBound();
}
const std::string
@@ -492,7 +494,7 @@ MemoryAccess::createBasicAccessMap(ScopS
void MemoryAccess::assumeNoOutOfBound() {
isl_space *Space = isl_space_range(getOriginalAccessRelationSpace());
isl_set *Outside = isl_set_empty(isl_space_copy(Space));
- for (int i = 1, Size = Subscripts.size(); i < Size; ++i) {
+ for (int i = 1, Size = isl_space_dim(Space, isl_dim_set); i < Size; ++i) {
isl_local_space *LS = isl_local_space_from_space(isl_space_copy(Space));
isl_pw_aff *Var =
isl_pw_aff_var_on_domain(isl_local_space_copy(LS), isl_dim_set, i);
@@ -501,10 +503,7 @@ void MemoryAccess::assumeNoOutOfBound()
isl_set *DimOutside;
DimOutside = isl_pw_aff_lt_set(isl_pw_aff_copy(Var), Zero);
- isl_pw_aff *SizeE = Statement->getPwAff(Sizes[i - 1]);
-
- SizeE = isl_pw_aff_drop_dims(SizeE, isl_dim_in, 0,
- Statement->getNumIterators());
+ isl_pw_aff *SizeE = getScopArrayInfo()->getDimensionSizePw(i);
SizeE = isl_pw_aff_add_dims(SizeE, isl_dim_in,
isl_space_dim(Space, isl_dim_set));
SizeE = isl_pw_aff_set_tuple_id(SizeE, isl_dim_in,
@@ -696,7 +695,6 @@ void MemoryAccess::buildAccessRelation(c
AccessRelation =
isl_map_set_tuple_id(AccessRelation, isl_dim_out, BaseAddrId);
- assumeNoOutOfBound();
AccessRelation = isl_map_gist_domain(AccessRelation, Statement->getDomain());
isl_space_free(Space);
}
@@ -1230,6 +1228,7 @@ void ScopStmt::deriveAssumptionsFromGEP(
isl_set *InBoundIfExecuted =
isl_set_union(isl_set_complement(Executed), InBound);
+ InBoundIfExecuted = isl_set_coalesce(InBoundIfExecuted);
Parent.addAssumption(INBOUNDS, InBoundIfExecuted, GEP->getDebugLoc());
}
Added: polly/trunk/test/ScopInfo/process_added_dimensions.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/process_added_dimensions.ll?rev=257170&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/process_added_dimensions.ll (added)
+++ polly/trunk/test/ScopInfo/process_added_dimensions.ll Fri Jan 8 08:01:59 2016
@@ -0,0 +1,104 @@
+; RUN: opt %loadPolly -polly-detect -polly-scops -analyze < %s | FileCheck %s
+
+; This test case produces the following memory access which we try hoist:
+; { Stmt_for_cond40_preheader_5[i0] -> MemRef_call[0, 0, 2240] }. However, it
+; accesses an array of size "i32 MemRef_call[*][6][64]". That is why we
+; should turn the whole SCoP into an invalid SCoP using corresponding bounds
+; checks. Otherwise, we derive the incorrect access.
+
+; CHECK: Valid Region for Scop: for.cond40.preheader.4 => for.end76
+; CHECK-NOT: Region: %for.cond40.preheader.4---%for.end76
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare noalias i8* @malloc()
+
+define void @main() {
+entry:
+ %call = tail call noalias i8* @malloc()
+ %0 = bitcast i8* %call to [6 x [6 x [64 x i32]]]*
+ %arrayidx51.5.phi.trans.insert = getelementptr inbounds i8, i8* %call, i64 8960
+ %1 = bitcast i8* %arrayidx51.5.phi.trans.insert to i32*
+ br label %for.cond40.preheader.4
+
+for.end76: ; preds = %for.inc71.5
+ ret void
+
+for.cond40.preheader.4: ; preds = %for.inc71.5, %entry
+ %t.0131 = phi i32 [ 0, %entry ], [ %inc75, %for.inc71.5 ]
+ %indvars.iv.next135 = add nuw nsw i64 0, 1
+ %2 = trunc i64 %indvars.iv.next135 to i32
+ %indvars.iv.next = add nuw nsw i64 0, 1
+ %exitcond = icmp eq i64 %indvars.iv.next, 64
+ %exitcond137 = icmp eq i32 %2, 6
+ %indvars.iv.next135.1 = add nuw nsw i64 1, 1
+ %indvars.iv.next.1 = add nuw nsw i64 0, 1
+ %exitcond.1 = icmp eq i64 %indvars.iv.next.1, 64
+ %lftr.wideiv.1 = trunc i64 %indvars.iv.next135.1 to i32
+ %exitcond137.1 = icmp eq i32 %lftr.wideiv.1, 6
+ %indvars.iv.next135.2 = add nuw nsw i64 2, 1
+ %indvars.iv.next.2 = add nuw nsw i64 0, 1
+ %exitcond.2 = icmp eq i64 %indvars.iv.next.2, 64
+ %lftr.wideiv.2 = trunc i64 %indvars.iv.next135.2 to i32
+ %exitcond137.2 = icmp eq i32 %lftr.wideiv.2, 6
+ %indvars.iv.next135.3 = add nuw nsw i64 3, 1
+ %indvars.iv.next.3 = add nuw nsw i64 0, 1
+ %exitcond.3 = icmp eq i64 %indvars.iv.next.3, 64
+ %lftr.wideiv.3 = trunc i64 %indvars.iv.next135.3 to i32
+ %exitcond137.3 = icmp eq i32 %lftr.wideiv.3, 6
+ %indvars.iv.next135.4 = add nuw nsw i64 4, 1
+ %indvars.iv.next.4 = add nuw nsw i64 0, 1
+ %exitcond.4 = icmp eq i64 %indvars.iv.next.4, 64
+ %lftr.wideiv.4 = trunc i64 %indvars.iv.next135.4 to i32
+ %exitcond137.4 = icmp eq i32 %lftr.wideiv.4, 6
+ %arrayidx23.5 = getelementptr inbounds [6 x [6 x [64 x i32]]], [6 x [6 x [64 x i32]]]* %0, i64 0, i64 5, i64 5, i64 0
+ store i32 36, i32* %arrayidx23.5, align 4
+ %indvars.iv.next.5 = add nuw nsw i64 0, 1
+ %exitcond.5 = icmp eq i64 %indvars.iv.next.5, 64
+ %indvars.iv.next143 = add nuw nsw i64 1, 1
+ %exitcond145 = icmp eq i64 %indvars.iv.next143, 64
+ %indvars.iv.next149 = add nuw nsw i64 0, 1
+ %lftr.wideiv150 = trunc i64 %indvars.iv.next149 to i32
+ %exitcond151 = icmp eq i32 %lftr.wideiv150, 6
+ %indvars.iv.next143.1 = add nuw nsw i64 1, 1
+ %exitcond145.1 = icmp eq i64 %indvars.iv.next143.1, 64
+ %indvars.iv.next149.1 = add nuw nsw i64 1, 1
+ %lftr.wideiv150.1 = trunc i64 %indvars.iv.next149.1 to i32
+ %exitcond151.1 = icmp eq i32 %lftr.wideiv150.1, 6
+ %indvars.iv.next143.2 = add nuw nsw i64 1, 1
+ %exitcond145.2 = icmp eq i64 %indvars.iv.next143.2, 64
+ %indvars.iv.next149.2 = add nuw nsw i64 2, 1
+ %lftr.wideiv150.2 = trunc i64 %indvars.iv.next149.2 to i32
+ %exitcond151.2 = icmp eq i32 %lftr.wideiv150.2, 6
+ %indvars.iv.next143.3 = add nuw nsw i64 1, 1
+ %exitcond145.3 = icmp eq i64 %indvars.iv.next143.3, 64
+ %indvars.iv.next149.3 = add nuw nsw i64 3, 1
+ %lftr.wideiv150.3 = trunc i64 %indvars.iv.next149.3 to i32
+ %exitcond151.3 = icmp eq i32 %lftr.wideiv150.3, 6
+ br label %for.body44.4
+
+for.body44.4: ; preds = %for.body44.4, %for.cond40.preheader.4
+ %indvars.iv142.4 = phi i64 [ 1, %for.cond40.preheader.4 ], [ %indvars.iv.next143.4, %for.body44.4 ]
+ %indvars.iv.next143.4 = add nuw nsw i64 %indvars.iv142.4, 1
+ %exitcond145.4 = icmp eq i64 %indvars.iv.next143.4, 64
+ br i1 %exitcond145.4, label %for.cond40.preheader.5, label %for.body44.4
+
+for.cond40.preheader.5: ; preds = %for.body44.4
+ %indvars.iv.next149.4 = add nuw nsw i64 4, 1
+ %lftr.wideiv150.4 = trunc i64 %indvars.iv.next149.4 to i32
+ %exitcond151.4 = icmp eq i32 %lftr.wideiv150.4, 6
+ %.pre160 = load i32, i32* %1, align 4
+ br label %for.body44.5
+
+for.body44.5: ; preds = %for.body44.5, %for.cond40.preheader.5
+ %indvars.iv142.5 = phi i64 [ 1, %for.cond40.preheader.5 ], [ %indvars.iv.next143.5, %for.body44.5 ]
+ %indvars.iv.next143.5 = add nuw nsw i64 %indvars.iv142.5, 1
+ %exitcond145.5 = icmp eq i64 %indvars.iv.next143.5, 64
+ br i1 %exitcond145.5, label %for.inc71.5, label %for.body44.5
+
+for.inc71.5: ; preds = %for.body44.5
+ %inc75 = add nuw nsw i32 %t.0131, 1
+ %exitcond155 = icmp eq i32 %inc75, 2
+ br i1 %exitcond155, label %for.end76, label %for.cond40.preheader.4
+}
Modified: polly/trunk/test/ScopInfo/remarks.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/remarks.ll?rev=257170&r1=257169&r2=257170&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/remarks.ll (original)
+++ polly/trunk/test/ScopInfo/remarks.ll Fri Jan 8 08:01:59 2016
@@ -3,7 +3,7 @@
; CHECK: remark: test/ScopInfo/remarks.c:4:7: SCoP begins here.
; CHECK: remark: test/ScopInfo/remarks.c:8:5: Finite loop assumption: [M, N, Debug] -> { : M >= 0 or (M <= -2 and N <= 0) or (M = -1 and N <= 0) }
; CHECK: remark: test/ScopInfo/remarks.c:13:7: No-error assumption: [M, N, Debug] -> { : M <= -1 or (M >= 0 and N <= 0) or (Debug = 0 and M >= 0 and N >= 1) }
-; CHECK: remark: test/ScopInfo/remarks.c:9:15: Inbounds assumption: [M, N, Debug] -> { : M <= 100 or (M >= 101 and N <= 0) }
+; CHECK: remark: test/ScopInfo/remarks.c:9:7: Inbounds assumption: [M, N, Debug] -> { : M <= 100 or (M >= 1 and N <= 0) }
; CHECK: remark: <unknown>:0:0: No-overflows assumption: [N, M, Debug] -> { : M <= 2147483647 - N and M >= -2147483648 - N }
; CHECK: remark: test/ScopInfo/remarks.c:9:18: Possibly aliasing pointer, use restrict keyword.
; CHECK: remark: test/ScopInfo/remarks.c:9:33: Possibly aliasing pointer, use restrict keyword.
Modified: polly/trunk/test/ScopInfo/user_provided_non_dominating_assumptions.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/user_provided_non_dominating_assumptions.ll?rev=257170&r1=257169&r2=257170&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/user_provided_non_dominating_assumptions.ll (original)
+++ polly/trunk/test/ScopInfo/user_provided_non_dominating_assumptions.ll Fri Jan 8 08:01:59 2016
@@ -1,8 +1,8 @@
; RUN: opt %loadPolly -pass-remarks-analysis="polly-scops" -polly-scops < %s 2>&1| FileCheck %s
;
; CHECK: remark: <unknown>:0:0: SCoP begins here.
-; CHECK-NEXT: remark: <unknown>:0:0: Inbounds assumption: [i, N, p_2, M] -> { : N <= i or (N >= 1 + i and p_2 <= 0) or (N >= 1 + i and p_2 >= 1 and M >= p_2) }
; CHECK-NEXT: remark: <unknown>:0:0: Inbounds assumption: [i, N, p_2] -> { : N <= i or (N >= 1 + i and p_2 <= 100) }
+; CHECK-NEXT: remark: <unknown>:0:0: Inbounds assumption: [i, N, p_2, M] -> { : N <= i or (N >= 1 + i and p_2 <= 0) or (N >= 1 + i and p_2 >= 1 and M >= p_2) }
; CHECK-NEXT: remark: <unknown>:0:0: SCoP ends here.
;
; void f(int *restrict A, int *restrict B, int i, int N, int M, int C[100][100]) {
More information about the llvm-commits
mailing list