From 8f8af43fefd1d0a413e88df77d1bea42b07f373c Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sun, 26 Apr 2015 20:07:21 +0000 Subject: [PATCH] Use all available range information for parameters In the following even full-range information will help to avoid runtime checks for wrapping integers, hence we enable it now. llvm-svn: 235823 --- polly/lib/Analysis/ScopInfo.cpp | 14 +++++--------- .../non_affine_conditional_surrounding_affine_loop.ll | 2 +- .../test/ScopInfo/NonAffine/non_affine_loop_used_later.ll | 2 +- polly/test/ScopInfo/assume_gep_bounds.ll | 6 +++++- polly/test/ScopInfo/assume_gep_bounds_2.ll | 6 +++++- .../multidim_3d_parametric_array_static_loop_bounds.ll | 6 +++++- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 2caab15..6f8de70 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -311,18 +311,18 @@ static __isl_give isl_set *addRangeBoundsToSet(__isl_take isl_set *S, isl_val *V; isl_ctx *ctx = isl_set_get_ctx(S); - bool isWrapping = Range.isSignWrappedSet(); - const auto LB = isWrapping ? Range.getLower() : Range.getSignedMin(); + bool useLowerUpperBound = Range.isSignWrappedSet() && !Range.isFullSet(); + const auto LB = useLowerUpperBound ? Range.getLower() : Range.getSignedMin(); V = isl_valFromAPInt(ctx, LB, true); isl_set *SLB = isl_set_lower_bound_val(isl_set_copy(S), type, dim, V); - const auto UB = isWrapping ? Range.getUpper() : Range.getSignedMax(); + const auto UB = useLowerUpperBound ? Range.getUpper() : Range.getSignedMax(); V = isl_valFromAPInt(ctx, UB, true); - if (isWrapping) + if (useLowerUpperBound) V = isl_val_sub_ui(V, 1); isl_set *SUB = isl_set_upper_bound_val(S, type, dim, V); - if (isWrapping) + if (useLowerUpperBound) return isl_set_union(SLB, SUB); else return isl_set_intersect(SLB, SUB); @@ -1345,10 +1345,6 @@ void Scop::addParameterBounds() { ConstantRange SRange = SE->getSignedRange(ParamID.first); - // TODO: Find a case where the full set is actually helpful. - if (SRange.isFullSet()) - continue; - Context = addRangeBoundsToSet(Context, SRange, dim, isl_dim_param); } } diff --git a/polly/test/ScopInfo/NonAffine/non_affine_conditional_surrounding_affine_loop.ll b/polly/test/ScopInfo/NonAffine/non_affine_conditional_surrounding_affine_loop.ll index 75b2064..44dd738 100644 --- a/polly/test/ScopInfo/NonAffine/non_affine_conditional_surrounding_affine_loop.ll +++ b/polly/test/ScopInfo/NonAffine/non_affine_conditional_surrounding_affine_loop.ll @@ -5,7 +5,7 @@ ; INNERMOST: Region: %bb9---%bb17 ; INNERMOST: Max Loop Depth: 1 ; INNERMOST: Context: -; INNERMOST: [N] -> { : } +; INNERMOST: [N] -> { : N >= -2147483648 and N <= 2147483647 } ; INNERMOST: Assumed Context: ; INNERMOST: [N] -> { : } ; INNERMOST: p0: %N diff --git a/polly/test/ScopInfo/NonAffine/non_affine_loop_used_later.ll b/polly/test/ScopInfo/NonAffine/non_affine_loop_used_later.ll index 3acc917..b78d269 100644 --- a/polly/test/ScopInfo/NonAffine/non_affine_loop_used_later.ll +++ b/polly/test/ScopInfo/NonAffine/non_affine_loop_used_later.ll @@ -7,7 +7,7 @@ ; CHECK: Region: %bb2---%bb24 ; CHECK: Max Loop Depth: 1 ; CHECK: Context: -; CHECK: [N] -> { : } +; CHECK: [N] -> { : N >= -2147483648 and N <= 2147483647 } ; CHECK: Assumed Context: ; CHECK: [N] -> { : } ; CHECK: p0: %N diff --git a/polly/test/ScopInfo/assume_gep_bounds.ll b/polly/test/ScopInfo/assume_gep_bounds.ll index c6938e6..0571b078 100644 --- a/polly/test/ScopInfo/assume_gep_bounds.ll +++ b/polly/test/ScopInfo/assume_gep_bounds.ll @@ -16,7 +16,11 @@ ; values for which our assumption holds. ; CHECK: Assumed Context -; CHECK-NEXT: [n, m, p] -> { : p <= 30 and m <= 20 } +; CHECK-NEXT: [n, m, p] -> { : +; CHECK-DAG: p <= 30 +; CHECK-DAG: and +; CHECK-DAG: m <= 20 +; CHECK: } target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/ScopInfo/assume_gep_bounds_2.ll b/polly/test/ScopInfo/assume_gep_bounds_2.ll index 6885e9f..0de5122 100644 --- a/polly/test/ScopInfo/assume_gep_bounds_2.ll +++ b/polly/test/ScopInfo/assume_gep_bounds_2.ll @@ -16,7 +16,11 @@ ; accessed. In this case the value of m does not matter. ; CHECK: Assumed Context: -; CHECK-NEXT: [n, m, p] -> { : (n >= 1 and m <= 20 and p <= 20) or (n <= 0 and p <= 20) } +; CHECK-NEXT: [n, m, p] -> { : +; CHECK-DAG: (n >= 1 and m <= 20 and p <= 20) +; CHECK-DAG: or +; CHECK-DAG: (n <= 0 and p <= 20) +; CHECK: } target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/polly/test/ScopInfo/multidim_3d_parametric_array_static_loop_bounds.ll b/polly/test/ScopInfo/multidim_3d_parametric_array_static_loop_bounds.ll index 0e38048..e0271c4 100644 --- a/polly/test/ScopInfo/multidim_3d_parametric_array_static_loop_bounds.ll +++ b/polly/test/ScopInfo/multidim_3d_parametric_array_static_loop_bounds.ll @@ -10,7 +10,11 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 ; } ; CHECK: Assumed Context: -; CHECK: [o, m] -> { : m >= 150 and o >= 200 } +; CHECK: [o, m] -> { : +; CHECK-DAG: m >= 150 +; CHECK-DAG: and +; CHECK-DAG: o >= 200 +; CHECK: } ; CHECK: p0: %o ; CHECK: p1: %m ; CHECK: Statements { -- 2.7.4