From e4bd53bd0cbae7ff571d911f0755365740334423 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sun, 8 Mar 2015 19:49:50 +0000 Subject: [PATCH] [FIX] Use the correct functions to extract the LB/UB from a range The current tests will continue to cover this code and more will be added when non-affine loops are supported. llvm-svn: 231606 --- polly/lib/Analysis/ScopInfo.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index 45645fb..cf7c10b 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -307,14 +307,18 @@ static __isl_give isl_set *addRangeBoundsToSet(__isl_take isl_set *S, isl_val *V; isl_ctx *ctx = isl_set_get_ctx(S); - V = isl_valFromAPInt(ctx, Range.getLower(), true); + bool isWrapping = Range.isSignWrappedSet(); + const auto LB = isWrapping ? 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); - V = isl_valFromAPInt(ctx, Range.getUpper(), true); - V = isl_val_sub_ui(V, 1); + const auto UB = isWrapping ? Range.getUpper() : Range.getSignedMax(); + V = isl_valFromAPInt(ctx, UB, true); + if (isWrapping) + V = isl_val_sub_ui(V, 1); isl_set *SUB = isl_set_upper_bound_val(S, type, dim, V); - if (Range.isSignWrappedSet()) + if (isWrapping) return isl_set_union(SLB, SUB); else return isl_set_intersect(SLB, SUB); @@ -550,9 +554,13 @@ void MemoryAccess::computeBoundsOnAccessRelation(unsigned ElementSize) { if (Range.isFullSet()) return; + bool isWrapping = Range.isSignWrappedSet(); unsigned BW = Range.getBitWidth(); - auto Min = Range.getSignedMin().sdiv(APInt(BW, ElementSize)); - auto Max = (Range.getSignedMax() - APInt(BW, 1)).sdiv(APInt(BW, ElementSize)); + const auto LB = isWrapping ? Range.getLower() : Range.getSignedMin(); + const auto UB = isWrapping ? Range.getUpper() : Range.getSignedMax(); + + auto Min = LB.sdiv(APInt(BW, ElementSize)); + auto Max = (UB - APInt(BW, 1)).sdiv(APInt(BW, ElementSize)); isl_set *AccessRange = isl_map_range(isl_map_copy(AccessRelation)); AccessRange = -- 2.7.4