mirror of git://gcc.gnu.org/git/gcc.git
re PR tree-optimization/82355 (ICE in outermost_loop_in_sese, at sese.c:301)
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. * gcc.dg/graphite/fuse-1.c: Adjust. * gcc.dg/graphite/fuse-2.c: Likewise. * gcc.dg/graphite/pr82355.c: New testcase. From-SVN: r253336
This commit is contained in:
parent
623c6df543
commit
0389d86c4e
|
|
@ -1,3 +1,20 @@
|
||||||
|
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>
|
2017-10-01 Kevin Buettner <kevinb@redhat.com>
|
||||||
|
|
||||||
* omp-expand.c (adjust_context_scope): New function.
|
* omp-expand.c (adjust_context_scope): New function.
|
||||||
|
|
|
||||||
|
|
@ -774,8 +774,10 @@ build_iv_mapping (vec<tree> iv_map, gimple_poly_bb_p gbb,
|
||||||
if (codegen_error_p ())
|
if (codegen_error_p ())
|
||||||
t = integer_zero_node;
|
t = integer_zero_node;
|
||||||
|
|
||||||
loop_p old_loop = gbb_loop_at_index (gbb, region, i - 1);
|
loop_p old_loop = gbb_loop_at_index (gbb, region, i - 2);
|
||||||
iv_map[old_loop->num] = t;
|
/* Record sth only for real loops. */
|
||||||
|
if (loop_in_sese_p (old_loop, region))
|
||||||
|
iv_map[old_loop->num] = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2587,18 +2589,6 @@ edge translate_isl_ast_to_gimple::
|
||||||
copy_bb_and_scalar_dependences (basic_block bb, edge next_e, vec<tree> iv_map)
|
copy_bb_and_scalar_dependences (basic_block bb, edge next_e, vec<tree> iv_map)
|
||||||
{
|
{
|
||||||
int num_phis = number_of_phi_nodes (bb);
|
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;
|
basic_block new_bb = NULL;
|
||||||
if (bb_contains_loop_close_phi_nodes (bb))
|
if (bb_contains_loop_close_phi_nodes (bb))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1055,10 +1055,12 @@ scop_detection::graphite_can_represent_expr (sese_l scop, loop_p loop,
|
||||||
bool
|
bool
|
||||||
scop_detection::stmt_has_simple_data_refs_p (sese_l scop, gimple *stmt)
|
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);
|
loop_p loop = loop_containing_stmt (stmt);
|
||||||
if (!loop_in_sese_p (loop, scop))
|
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;
|
auto_vec<data_reference_p> drs;
|
||||||
if (! graphite_find_data_references_in_stmt (nest, loop, stmt, &drs))
|
if (! graphite_find_data_references_in_stmt (nest, loop, stmt, &drs))
|
||||||
|
|
@ -1450,11 +1452,12 @@ try_generate_gimple_bb (scop_p scop, basic_block bb)
|
||||||
vec<scalar_use> reads = vNULL;
|
vec<scalar_use> reads = vNULL;
|
||||||
|
|
||||||
sese_l region = scop->scop_info->region;
|
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;
|
loop_p loop = bb->loop_father;
|
||||||
if (!loop_in_sese_p (loop, region))
|
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);
|
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
|
||||||
gsi_next (&gsi))
|
gsi_next (&gsi))
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ extract_affine_chrec (scop_p s, tree e, __isl_take isl_space *space)
|
||||||
isl_pw_aff *lhs = extract_affine (s, CHREC_LEFT (e), isl_space_copy (space));
|
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_pw_aff *rhs = extract_affine (s, CHREC_RIGHT (e), isl_space_copy (space));
|
||||||
isl_local_space *ls = isl_local_space_from_space (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 *loop = isl_aff_set_coefficient_si
|
||||||
(isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1);
|
(isl_aff_zero_on_domain (ls), isl_dim_in, pos, 1);
|
||||||
isl_pw_aff *l = isl_pw_aff_from_aff (loop);
|
isl_pw_aff *l = isl_pw_aff_from_aff (loop);
|
||||||
|
|
@ -756,10 +756,10 @@ add_loop_constraints (scop_p scop, __isl_take isl_set *domain, loop_p loop,
|
||||||
return domain;
|
return domain;
|
||||||
const sese_l ®ion = scop->scop_info->region;
|
const sese_l ®ion = scop->scop_info->region;
|
||||||
if (!loop_in_sese_p (loop, region))
|
if (!loop_in_sese_p (loop, region))
|
||||||
return domain;
|
;
|
||||||
|
else
|
||||||
/* Recursion all the way up to the context loop. */
|
/* Recursion all the way up to the context loop. */
|
||||||
domain = add_loop_constraints (scop, domain, loop_outer (loop), context);
|
domain = add_loop_constraints (scop, domain, loop_outer (loop), context);
|
||||||
|
|
||||||
/* Then, build constraints over the loop in post-order: outer to inner. */
|
/* Then, build constraints over the loop in post-order: outer to inner. */
|
||||||
|
|
||||||
|
|
@ -770,6 +770,21 @@ add_loop_constraints (scop_p scop, __isl_take isl_set *domain, loop_p loop,
|
||||||
domain = add_iter_domain_dimension (domain, loop, scop);
|
domain = add_iter_domain_dimension (domain, loop, scop);
|
||||||
isl_space *space = isl_set_get_space (domain);
|
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 */
|
/* 0 <= loop_i */
|
||||||
isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space));
|
isl_local_space *ls = isl_local_space_from_space (isl_space_copy (space));
|
||||||
isl_constraint *c = isl_inequality_alloc (ls);
|
isl_constraint *c = isl_inequality_alloc (ls);
|
||||||
|
|
|
||||||
|
|
@ -326,8 +326,6 @@ gbb_loop_at_index (gimple_poly_bb_p gbb, sese_l ®ion, int index)
|
||||||
while (--depth > index)
|
while (--depth > index)
|
||||||
loop = loop_outer (loop);
|
loop = loop_outer (loop);
|
||||||
|
|
||||||
gcc_assert (loop_in_sese_p (loop, region));
|
|
||||||
|
|
||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
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>
|
2017-10-01 Jeff Law <law@redhat.com>
|
||||||
|
|
||||||
* gcc.dg/tree-ssa/ssa-dom-simplify-1.c: New test.
|
* gcc.dg/tree-ssa/ssa-dom-simplify-1.c: New test.
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
/* Check that the two loops are fused and that we manage to fold the two xor
|
/* Check that the two loops are fused and that we manage to fold the two xor
|
||||||
operations. */
|
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:
|
/* Make sure we fuse the loops like this:
|
||||||
AST generated by isl:
|
AST generated by isl:
|
||||||
for (int c0 = 0; c0 <= 99; c0 += 1) {
|
for (int c0 = 0; c0 <= 99; c0 += 1) {
|
||||||
S_3(c0);
|
S_3(0, c0);
|
||||||
S_6(c0);
|
S_6(0, c0);
|
||||||
S_9(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. */
|
/* 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" } } */
|
/* { dg-final { scan-tree-dump-times "gimple_simplified to\[^\\n\]*\\^ 12" 1 "forwprop4" } } */
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
/* Make sure we fuse the loops like this:
|
/* Make sure we fuse the loops like this:
|
||||||
AST generated by isl:
|
AST generated by isl:
|
||||||
for (int c0 = 0; c0 <= 99; c0 += 1) {
|
for (int c0 = 0; c0 <= 99; c0 += 1) {
|
||||||
S_3(c0);
|
S_3(0, c0);
|
||||||
S_6(c0);
|
S_6(0, c0);
|
||||||
S_9(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
|
#define MAX 100
|
||||||
int A[MAX], B[MAX], C[MAX];
|
int A[MAX], B[MAX], C[MAX];
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* { 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue