diff options
author | Aditya Kumar <aditya.k7@samsung.com> | 2015-07-17 16:34:21 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2015-07-17 16:34:21 +0000 |
commit | 247577525613274ed246537f195eda285087d814 (patch) | |
tree | f5c008a61cb11b8aae86f54269a208938816706b /gcc/graphite-interchange.c | |
parent | 9298e25f6c5d5606fa140aa6a192b72f201daa56 (diff) | |
download | gcc-247577525613274ed246537f195eda285087d814.zip gcc-247577525613274ed246537f195eda285087d814.tar.gz gcc-247577525613274ed246537f195eda285087d814.tar.bz2 |
[graphite] fix pr61929
This fixes bootstrap of GCC with BOOT_CFLAGS="-g -O2 -fgraphite-identity
-floop-nest-optimize -floop-block -floop-interchange -floop-strip-mine". It
passes regstrap on amd64-linux. A previous change
(https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=213816), replaced
isl_int with isl_val because isl_int would be deprecated. Since isl_val has
stricter checks, it exposed the bug. In the test case (isl_set_max_val) would
return infinity which would remain unchecked. We now check if the value
returned is an integer or not, and bail out if it isn't. The other problem was
that we were allowing all kinds of data-refs in a scop. Now we discard a scop
if it has any date-ref other than (ARRAY_REF, MEM_REF, COMPONENT_REF).
PR middle-end/61929
* graphite-dependences.c (add_pdr_constraints): Renamed
pdr->extent to pdr->subscript_sizes.
* graphite-interchange.c (build_linearized_memory_access): Add
back all gcc_assert's that the "isl_int to isl_val conversion"
patch has removed. Refactored.
(pdr_stride_in_loop): Renamed pdr->extent to pdr->subscript_sizes.
* graphite-poly.c (new_poly_dr): Same.
(free_poly_dr): Same.
* graphite-poly.h (struct poly_dr): Same.
* graphite-scop-detection.c (stmt_has_simple_data_refs_p): Ignore
all data references other than ARRAY_REF, MEM_REF, and COMPONENT_REF.
* graphite-scop-detection.h: Fix space.
* graphite-sese-to-poly.c (build_pbb_scattering_polyhedrons): Add
back all gcc_assert's removed by a previous patch.
(wrap): Remove the_isl_ctx global variable that the same patch has
added.
(build_loop_iteration_domains): Same.
(add_param_constraints): Same.
(pdr_add_data_dimensions): Same. Refactored.
(build_poly_dr): Renamed extent to subscript_sizes.
testsuite/
PR middle-end/61929
* gcc.dg/graphite/pr61929.c: New.
Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r225942
Diffstat (limited to 'gcc/graphite-interchange.c')
-rw-r--r-- | gcc/graphite-interchange.c | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/gcc/graphite-interchange.c b/gcc/graphite-interchange.c index aee51a8..03c2c63 100644 --- a/gcc/graphite-interchange.c +++ b/gcc/graphite-interchange.c @@ -79,37 +79,40 @@ extern "C" { static isl_constraint * build_linearized_memory_access (isl_map *map, poly_dr_p pdr) { - isl_constraint *res; isl_local_space *ls = isl_local_space_from_space (isl_map_get_space (map)); - unsigned offset, nsubs; - int i; - isl_ctx *ctx; + isl_constraint *res = isl_equality_alloc (ls); + isl_val *size = isl_val_int_from_ui (isl_map_get_ctx (map), 1); - isl_val *size, *subsize, *size1; - - res = isl_equality_alloc (ls); - ctx = isl_local_space_get_ctx (ls); - size = isl_val_int_from_ui (ctx, 1); - - nsubs = isl_set_dim (pdr->extent, isl_dim_set); + unsigned nsubs = isl_set_dim (pdr->subscript_sizes, isl_dim_set); /* -1 for the already included L dimension. */ - offset = isl_map_dim (map, isl_dim_out) - 1 - nsubs; + unsigned offset = isl_map_dim (map, isl_dim_out) - 1 - nsubs; res = isl_constraint_set_coefficient_si (res, isl_dim_out, offset + nsubs, -1); - /* Go through all subscripts from last to first. First dimension + /* Go through all subscripts from last to first. The dimension "i=0" is the alias set, ignore it. */ - for (i = nsubs - 1; i >= 1; i--) + for (int i = nsubs - 1; i >= 1; i--) { - isl_space *dc; - isl_aff *aff; - - size1 = isl_val_copy (size); - res = isl_constraint_set_coefficient_val (res, isl_dim_out, offset + i, size); - dc = isl_set_get_space (pdr->extent); - aff = isl_aff_zero_on_domain (isl_local_space_from_space (dc)); - aff = isl_aff_set_coefficient_si (aff, isl_dim_in, i, 1); - subsize = isl_set_max_val (pdr->extent, aff); - isl_aff_free (aff); - size = isl_val_mul (size1, subsize); + isl_aff *extract_dim; + res = isl_constraint_set_coefficient_val (res, isl_dim_out, offset + i, + isl_val_copy (size)); + isl_space *dc = isl_set_get_space (pdr->subscript_sizes); + extract_dim = isl_aff_zero_on_domain (isl_local_space_from_space (dc)); + extract_dim = isl_aff_set_coefficient_si (extract_dim, isl_dim_in, i, 1); + isl_val *max = isl_set_max_val (pdr->subscript_sizes, extract_dim); + isl_aff_free (extract_dim); + + /* The result is NULL in case of an error, the optimal value in case there + is one, negative infinity or infinity if the problem is unbounded and + NaN if the problem is empty. */ + gcc_assert (max); + + /* When one of the dimensions cannot be computed, we cannot build the size + of the array for any outer dimensions. */ + if (!isl_val_is_int (max)) + { + isl_val_free (max); + break; + } + size = isl_val_mul (size, max); } isl_val_free (size); @@ -176,7 +179,7 @@ pdr_stride_in_loop (mpz_t stride, graphite_dim_t depth, poly_dr_p pdr) /* pdr->accesses: [P1..nb_param,I1..nb_domain]->[a,S1..nb_subscript] ??? [P] not used for PDRs? - pdr->extent: [a,S1..nb_subscript] + pdr->subscript_sizes: [a,S1..nb_subscript] pbb->domain: [P1..nb_param,I1..nb_domain] pbb->transformed: [P1..nb_param,I1..nb_domain]->[T1..Tnb_sctr] [T] includes local vars (currently unused) |