summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-02 07:32:52 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-02 07:32:52 +0000
commit5f5772fbd374a3844ceefe1bbae44b3d38e707a4 (patch)
tree83af0087c3c1be8a0a44f85b0ac7b545e5279af2
parent330a2f10656a09423d03308fc36237b0af5d5e04 (diff)
downloadgcc-5f5772fbd374a3844ceefe1bbae44b3d38e707a4.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253336 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/graphite-isl-ast-to-gimple.c18
-rw-r--r--gcc/graphite-scop-detection.c13
-rw-r--r--gcc/graphite-sese-to-poly.c25
-rw-r--r--gcc/sese.h2
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/graphite/fuse-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/graphite/fuse-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/graphite/pr82355.c23
9 files changed, 88 insertions, 35 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ede5fb075dd..d5b0b6fee47 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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>
* omp-expand.c (adjust_context_scope): New function.
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 820e14ec517..fb91ba15eac 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -774,8 +774,10 @@ build_iv_mapping (vec<tree> iv_map, gimple_poly_bb_p gbb,
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;
}
}
@@ -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)
{
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))
{
diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index b374ee1a4e1..eed4efa3e05 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -1055,10 +1055,12 @@ scop_detection::graphite_can_represent_expr (sese_l scop, loop_p loop,
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))
@@ -1450,11 +1452,12 @@ try_generate_gimple_bb (scop_p scop, basic_block bb)
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))
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 087a44a891d..8611e86cc60 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -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 *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);
@@ -756,10 +756,10 @@ add_loop_constraints (scop_p scop, __isl_take isl_set *domain, loop_p loop,
return domain;
const sese_l &region = 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. */
@@ -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);
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);
diff --git a/gcc/sese.h b/gcc/sese.h
index 3bdb34c1a67..f1371ee9d35 100644
--- a/gcc/sese.h
+++ b/gcc/sese.h
@@ -326,8 +326,6 @@ gbb_loop_at_index (gimple_poly_bb_p gbb, sese_l &region, int index)
while (--depth > index)
loop = loop_outer (loop);
- gcc_assert (loop_in_sese_p (loop, region));
-
return loop;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d12fbdd86a5..2faad379a88 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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>
* gcc.dg/tree-ssa/ssa-dom-simplify-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/graphite/fuse-1.c b/gcc/testsuite/gcc.dg/graphite/fuse-1.c
index 204d3b20703..e3bf7bcf99b 100644
--- a/gcc/testsuite/gcc.dg/graphite/fuse-1.c
+++ b/gcc/testsuite/gcc.dg/graphite/fuse-1.c
@@ -1,15 +1,15 @@
/* 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" } } */
diff --git a/gcc/testsuite/gcc.dg/graphite/fuse-2.c b/gcc/testsuite/gcc.dg/graphite/fuse-2.c
index f4cea4360d9..dc0a9b2b61c 100644
--- a/gcc/testsuite/gcc.dg/graphite/fuse-2.c
+++ b/gcc/testsuite/gcc.dg/graphite/fuse-2.c
@@ -3,13 +3,13 @@
/* 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];
diff --git a/gcc/testsuite/gcc.dg/graphite/pr82355.c b/gcc/testsuite/gcc.dg/graphite/pr82355.c
new file mode 100644
index 00000000000..b60772dc125
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr82355.c
@@ -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)
+ {
+ }
+ }
+}