[polly] r231606 - [FIX] Use the correct functions to extract the LB/UB from a range
Johannes Doerfert
doerfert at cs.uni-saarland.de
Sun Mar 8 12:49:50 PDT 2015
Author: jdoerfert
Date: Sun Mar 8 14:49:50 2015
New Revision: 231606
URL: http://llvm.org/viewvc/llvm-project?rev=231606&view=rev
Log:
[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.
Modified:
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=231606&r1=231605&r2=231606&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sun Mar 8 14:49:50 2015
@@ -307,14 +307,18 @@ static __isl_give isl_set *addRangeBound
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::computeBoundsOnAccess
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 =
More information about the llvm-commits
mailing list