+2017-10-02 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/82355
+ * graphite-isl-ast-to-gimple.c (build_iv_mapping): Also build
+ a mapping for the enclosing loop but avoid generating one for
+ the loop tree root.
+ (copy_bb_and_scalar_dependences): Remove premature codegen
+ error on PHIs in blocks duplicated into multiple places.
+ * graphite-scop-detection.c
+ (scop_detection::stmt_has_simple_data_refs_p): For a loop not
+ in the region use it as loop and nest to analyze the DR in.
+ (try_generate_gimple_bb): Likewise.
+ * graphite-sese-to-poly.c (extract_affine_chrec): Adjust.
+ (add_loop_constraints): For blocks in a loop not in the region
+ create a dimension with a single iteration.
+ * sese.h (gbb_loop_at_index): Remove assert.
+
2017-10-01 Kevin Buettner <kevinb@redhat.com>
* omp-expand.c (adjust_context_scope): New function.
if (codegen_error_p ())
t = integer_zero_node;
- loop_p old_loop = gbb_loop_at_index (gbb, region, i - 1);
- iv_map[old_loop->num] = t;
+ loop_p old_loop = gbb_loop_at_index (gbb, region, i - 2);
+ /* Record sth only for real loops. */
+ if (loop_in_sese_p (old_loop, region))
+ iv_map[old_loop->num] = t;
}
}
copy_bb_and_scalar_dependences (basic_block bb, edge next_e, vec<tree> iv_map)
{
int num_phis = number_of_phi_nodes (bb);
-
- if (region->copied_bb_map->get (bb))
- {
- /* FIXME: we should be able to handle phi nodes with args coming from
- outside the region. */
- if (num_phis)
- {
- set_codegen_error ();
- return NULL;
- }
- }
-
basic_block new_bb = NULL;
if (bb_contains_loop_close_phi_nodes (bb))
{
bool
scop_detection::stmt_has_simple_data_refs_p (sese_l scop, gimple *stmt)
{
- loop_p nest = outermost_loop_in_sese (scop, gimple_bb (stmt));
+ loop_p nest;
loop_p loop = loop_containing_stmt (stmt);
if (!loop_in_sese_p (loop, scop))
- loop = nest;
+ nest = loop;
+ else
+ nest = outermost_loop_in_sese (scop, gimple_bb (stmt));
auto_vec<data_reference_p> drs;
if (! graphite_find_data_references_in_stmt (nest, loop, stmt, &drs))
vec<scalar_use> reads = vNULL;
sese_l region = scop->scop_info->region;
- loop_p nest = outermost_loop_in_sese (region, bb);
-
+ loop_p nest;
loop_p loop = bb->loop_father;
if (!loop_in_sese_p (loop, region))
- loop = nest;
+ nest = loop;
+ else
+ nest = outermost_loop_in_sese (region, bb);
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
gsi_next (&gsi))
isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e), isl_space_copy (space));
isl_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e), isl_space_copy (space));
isl_local_space *ls = isl_local_space_from_space (space);
- unsigned pos = sese_loop_depth (s->scop_info->region, get_chrec_loop (e)) - 1;
+ unsigned pos = sese_loop_depth (s->scop_info->region, get_chrec_loop (e));
isl_aff *loop = isl_aff_set_coefficient_si
(isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1);
isl_pw_aff *l = isl_pw_aff_from_aff (loop);
return domain;
const sese_l ®ion = scop->scop_info->region;
if (!loop_in_sese_p (loop, region))
- return domain;
-
- /* Recursion all the way up to the context loop. */
- domain = add_loop_constraints (scop, domain, loop_outer (loop), context);
+ ;
+ else
+ /* Recursion all the way up to the context loop. */
+ domain = add_loop_constraints (scop, domain, loop_outer (loop), context);
/* Then, build constraints over the loop in post-order: outer to inner. */
domain = add_iter_domain_dimension (domain, loop, scop);
isl_space *space = isl_set_get_space (domain);
+ if (!loop_in_sese_p (loop, region))
+ {
+ /* 0 == loop_i */
+ isl_local_space *ls = isl_local_space_from_space (space);
+ isl_constraint *c = isl_equality_alloc (ls);
+ c = isl_constraint_set_coefficient_si (c, isl_dim_set, loop_index, 1);
+ if (dump_file)
+ {
+ fprintf (dump_file, "[sese-to-poly] adding constraint to the domain: ");
+ print_isl_constraint (dump_file, c);
+ }
+ domain = isl_set_add_constraint (domain, c);
+ return domain;
+ }
+
/* 0 <= loop_i */
isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space));
isl_constraint *c = isl_inequality_alloc (ls);
while (--depth > index)
loop = loop_outer (loop);
- gcc_assert (loop_in_sese_p (loop, region));
-
return loop;
}
+2017-10-02 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/82355
+ * gcc.dg/graphite/fuse-1.c: Adjust.
+ * gcc.dg/graphite/fuse-2.c: Likewise.
+ * gcc.dg/graphite/pr82355.c: New testcase.
+
2017-10-01 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-dom-simplify-1.c: New test.
/* Check that the two loops are fused and that we manage to fold the two xor
operations. */
-/* { dg-options "-O2 -floop-nest-optimize -fdump-tree-forwprop-all -fdump-tree-graphite-all" } */
+/* { dg-options "-O2 -floop-nest-optimize -fdump-tree-forwprop4-all -fdump-tree-graphite-all" } */
/* Make sure we fuse the loops like this:
AST generated by isl:
for (int c0 = 0; c0 <= 99; c0 += 1) {
- S_3(c0);
- S_6(c0);
- S_9(c0);
+ S_3(0, c0);
+ S_6(0, c0);
+ S_9(0, c0);
} */
-/* { dg-final { scan-tree-dump-times "AST generated by isl:.*for \\(int c0 = 0; c0 <= 99; c0 \\+= 1\\) \\{.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*\\}" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "AST generated by isl:.*for \\(int c0 = 0; c0 <= 99; c0 \\+= 1\\) \\{.*S_.*\\(0, c0\\);.*S_.*\\(0, c0\\);.*S_.*\\(0, c0\\);.*\\}" 1 "graphite" } } */
/* Check that after fusing the loops, the scalar computation is also fused. */
/* { dg-final { scan-tree-dump-times "gimple_simplified to\[^\\n\]*\\^ 12" 1 "forwprop4" } } */
/* Make sure we fuse the loops like this:
AST generated by isl:
for (int c0 = 0; c0 <= 99; c0 += 1) {
- S_3(c0);
- S_6(c0);
- S_9(c0);
+ S_3(0, c0);
+ S_6(0, c0);
+ S_9(0, c0);
}
*/
-/* { dg-final { scan-tree-dump-times "AST generated by isl:.*for \\(int c0 = 0; c0 <= 99; c0 \\+= 1\\) \\{.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*S_.*\\(c0\\);.*\\}" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "AST generated by isl:.*for \\(int c0 = 0; c0 <= 99; c0 \\+= 1\\) \\{.*S_.*\\(0, c0\\);.*S_.*\\(0, c0\\);.*S_.*\\(0, c0\\);.*\\}" 1 "graphite" } } */
#define MAX 100
int A[MAX], B[MAX], C[MAX];
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -floop-nest-optimize" } */
+
+int dc, at;
+
+void
+tv (int *ld, int jl)
+{
+ for (;;)
+ {
+ if (dc != 0)
+ for (;;)
+ {
+ *ld = !!(*ld) + 1;
+ for (dc = 0; dc < 3; ++dc)
+ at = (jl != 0) ? *ld : 0;
+ }
+
+ while (at != 0)
+ {
+ }
+ }
+}