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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225942
138bc75d-0d04-0410-961f-
82ee72b054a4
+2015-07-17 Aditya Kumar <aditya.k7@samsung.com>
+ Sebastian Pop <s.pop@samsung.com>
+
+ 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.
+
2015-07-17 Marek Polacek <polacek@redhat.com>
* fold-const.c (fold_binary_loc): Move A - (A & B) into ~B & A ...
return isl_map_intersect_domain (map, s);
}
-/* Constrain pdr->accesses with pdr->extent and pbb->domain. */
+/* Constrain pdr->accesses with pdr->subscript_sizes and pbb->domain. */
static isl_map *
add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
{
isl_map *x = isl_map_intersect_range (isl_map_copy (pdr->accesses),
- isl_set_copy (pdr->extent));
+ isl_set_copy (pdr->subscript_sizes));
x = constrain_domain (x, isl_set_copy (pbb->domain));
return x;
}
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);
/* 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)
void
new_poly_dr (poly_bb_p pbb, int dr_base_object_set,
enum poly_dr_type type, void *cdr, graphite_dim_t nb_subscripts,
- isl_map *acc, isl_set *extent)
+ isl_map *acc, isl_set *subscript_sizes)
{
static int id = 0;
poly_dr_p pdr = XNEW (struct poly_dr);
PDR_NB_REFS (pdr) = 1;
PDR_PBB (pdr) = pbb;
pdr->accesses = acc;
- pdr->extent = extent;
+ pdr->subscript_sizes = subscript_sizes;
PDR_TYPE (pdr) = type;
PDR_CDR (pdr) = cdr;
PDR_NB_SUBSCRIPTS (pdr) = nb_subscripts;
free_poly_dr (poly_dr_p pdr)
{
isl_map_free (pdr->accesses);
- isl_set_free (pdr->extent);
+ isl_set_free (pdr->subscript_sizes);
XDELETE (pdr);
}
In the example, the vector "R C O I L P" is "7 7 3 2 0 1". */
isl_map *accesses;
- isl_set *extent;
+ isl_set *subscript_sizes;
/* Data reference's base object set number, we must assure 2 pdrs are in the
same base object set before dependency checking. */
gimple stmt)
{
data_reference_p dr;
- unsigned i;
int j;
bool res = true;
vec<data_reference_p> drs = vNULL;
stmt, &drs);
FOR_EACH_VEC_ELT (drs, j, dr)
- for (i = 0; i < DR_NUM_DIMENSIONS (dr); i++)
- if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i)))
+ {
+ int nb_subscripts = DR_NUM_DIMENSIONS (dr);
+ tree ref = DR_REF (dr);
+
+ for (int i = nb_subscripts - 1; i >= 0; i--)
{
- res = false;
- goto done;
+ if (!graphite_can_represent_scev (DR_ACCESS_FN (dr, i))
+ || (TREE_CODE (ref) != ARRAY_REF
+ && TREE_CODE (ref) != MEM_REF
+ && TREE_CODE (ref) != COMPONENT_REF))
+ {
+ free_data_refs (drs);
+ return false;
+ }
+
+ ref = TREE_OPERAND (ref, 0);
}
+ }
free_data_refs (drs);
drs.create (0);
}
- done:
free_data_refs (drs);
return res;
}
#define GCC_GRAPHITE_SCOP_DETECTION_H
extern void build_scops (vec<scop_p> *);
-extern void dot_all_scops (vec<scop_p> );
+extern void dot_all_scops (vec<scop_p>);
extern void dot_scop (scop_p);
#endif /* GCC_GRAPHITE_SCOP_DETECTION_H */
(isl_local_space_from_space (isl_map_get_space (pbb->schedule)));
val = isl_aff_get_coefficient_val (static_sched, isl_dim_in, i / 2);
+ gcc_assert (val && isl_val_is_int (val));
val = isl_val_neg (val);
c = isl_constraint_set_constant_val (c, val);
/* Compute pwaff mod 2^width. */
-extern isl_ctx *the_isl_ctx;
-
static isl_pw_aff *
wrap (isl_pw_aff *pwaff, unsigned width)
{
isl_val *mod;
- mod = isl_val_int_from_ui(the_isl_ctx, width);
+ mod = isl_val_int_from_ui (isl_pw_aff_get_ctx (pwaff), width);
mod = isl_val_2exp (mod);
pwaff = isl_pw_aff_mod_val (pwaff, mod);
(isl_local_space_from_space (isl_space_copy (space)));
c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
tree_int_to_gmp (nb_iters, g);
- v = isl_val_int_from_gmp (the_isl_ctx, g);
+ v = isl_val_int_from_gmp (scop->ctx, g);
c = isl_constraint_set_constant_val (c, v);
inner = isl_set_add_constraint (inner, c);
}
c = isl_inequality_alloc
(isl_local_space_from_space (isl_space_copy (space)));
c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
- v = isl_val_int_from_gmp (the_isl_ctx, g);
+ v = isl_val_int_from_gmp (scop->ctx, g);
mpz_clear (g);
c = isl_constraint_set_constant_val (c, v);
inner = isl_set_add_constraint (inner, c);
c = isl_inequality_alloc (isl_local_space_from_space (space));
mpz_init (g);
tree_int_to_gmp (lb, g);
- v = isl_val_int_from_gmp (the_isl_ctx, g);
+ v = isl_val_int_from_gmp (scop->ctx, g);
v = isl_val_neg (v);
mpz_clear (g);
c = isl_constraint_set_constant_val (c, v);
mpz_init (g);
tree_int_to_gmp (ub, g);
- v = isl_val_int_from_gmp (the_isl_ctx, g);
+ v = isl_val_int_from_gmp (scop->ctx, g);
mpz_clear (g);
c = isl_constraint_set_constant_val (c, v);
c = isl_constraint_set_coefficient_si (c, isl_dim_param, p, -1);
domain. */
static isl_set *
-pdr_add_data_dimensions (isl_set *extent, scop_p scop, data_reference_p dr)
+pdr_add_data_dimensions (isl_set *subscript_sizes, scop_p scop,
+ data_reference_p dr)
{
tree ref = DR_REF (dr);
- int i, nb_subscripts = DR_NUM_DIMENSIONS (dr);
- for (i = nb_subscripts - 1; i >= 0; i--, ref = TREE_OPERAND (ref, 0))
+ int nb_subscripts = DR_NUM_DIMENSIONS (dr);
+ for (int i = nb_subscripts - 1; i >= 0; i--, ref = TREE_OPERAND (ref, 0))
{
- tree low, high;
-
if (TREE_CODE (ref) != ARRAY_REF)
- break;
+ return subscript_sizes;
- low = array_ref_low_bound (ref);
- high = array_ref_up_bound (ref);
+ tree low = array_ref_low_bound (ref);
+ tree high = array_ref_up_bound (ref);
/* XXX The PPL code dealt separately with
subscript - low >= 0 and high - subscript >= 0 in case one of
isl_aff *aff;
isl_set *univ, *lbs, *ubs;
isl_pw_aff *index;
- isl_space *space;
isl_set *valid;
- isl_pw_aff *lb = extract_affine_int (low, isl_set_get_space (extent));
- isl_pw_aff *ub = extract_affine_int (high, isl_set_get_space (extent));
+ isl_space *space = isl_set_get_space (subscript_sizes);
+ isl_pw_aff *lb = extract_affine_int (low, isl_space_copy (space));
+ isl_pw_aff *ub = extract_affine_int (high, isl_space_copy (space));
/* high >= 0 */
valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (ub));
isl_set_dim (valid, isl_dim_set));
scop->context = isl_set_intersect (scop->context, valid);
- space = isl_set_get_space (extent);
aff = isl_aff_zero_on_domain (isl_local_space_from_space (space));
aff = isl_aff_add_coefficient_si (aff, isl_dim_in, i + 1, 1);
univ = isl_set_universe (isl_space_domain (isl_aff_get_space (aff)));
index = isl_pw_aff_alloc (univ, aff);
- id = isl_set_get_tuple_id (extent);
+ id = isl_set_get_tuple_id (subscript_sizes);
lb = isl_pw_aff_set_tuple_id (lb, isl_dim_in, isl_id_copy (id));
ub = isl_pw_aff_set_tuple_id (ub, isl_dim_in, id);
/* low <= sub_i <= high */
lbs = isl_pw_aff_ge_set (isl_pw_aff_copy (index), lb);
ubs = isl_pw_aff_le_set (index, ub);
- extent = isl_set_intersect (extent, lbs);
- extent = isl_set_intersect (extent, ubs);
+ subscript_sizes = isl_set_intersect (subscript_sizes, lbs);
+ subscript_sizes = isl_set_intersect (subscript_sizes, ubs);
}
}
- return extent;
+ return subscript_sizes;
}
/* Build data accesses for DR in PBB. */
{
int dr_base_object_set;
isl_map *acc;
- isl_set *extent;
+ isl_set *subscript_sizes;
scop_p scop = PBB_SCOP (pbb);
{
alias_set_num = *(bap->alias_set);
space = isl_space_set_tuple_id (space, isl_dim_set, id);
- extent = isl_set_nat_universe (space);
- extent = isl_set_fix_si (extent, isl_dim_set, 0, alias_set_num);
- extent = pdr_add_data_dimensions (extent, scop, dr);
+ subscript_sizes = isl_set_nat_universe (space);
+ subscript_sizes = isl_set_fix_si (subscript_sizes, isl_dim_set, 0,
+ alias_set_num);
+ subscript_sizes = pdr_add_data_dimensions (subscript_sizes, scop, dr);
}
gcc_assert (dr->aux);
new_poly_dr (pbb, dr_base_object_set,
DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
- dr, DR_NUM_DIMENSIONS (dr), acc, extent);
+ dr, DR_NUM_DIMENSIONS (dr), acc, subscript_sizes);
}
/* Write to FILE the alias graph of data references in DIMACS format. */
+2015-07-17 Aditya Kumar <aditya.k7@samsung.com>
+ Sebastian Pop <s.pop@samsung.com>
+
+ PR middle-end/61929
+ * gcc.dg/graphite/pr61929.c: New.
+
2015-07-17 Marek Polacek <polacek@redhat.com>
* gcc.dg/fold-minus-7.c: New test.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-linear -floop-strip-mine" } */
+
+typedef struct m {
+ char *A;
+ char *B;
+} mystruct;
+mystruct arr[52];
+
+void main () {}
+void generateICE (void)
+{
+ int i;
+ for (i=0; i<52; i++)
+ {
+ arr[i].A = "";
+ arr[i].B = 0;
+ }
+}