This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, PR68460] Always call free_stmt_vec_info_vec in gather_scalar_reductions
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: "gcc-patches at gnu dot org" <gcc-patches at gnu dot org>
- Date: Fri, 20 Nov 2015 16:57:00 +0100
- Subject: [PATCH, PR68460] Always call free_stmt_vec_info_vec in gather_scalar_reductions
- Authentication-results: sourceware.org; auth=none
- References: <56182D1D dot 2060106 at mentor dot com>
[ was: Re: [PATCH] Fix parloops gimple_uid usage ]
On 09/10/15 23:09, Tom de Vries wrote:
@@ -2392,6 +2397,9 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
loop_vec_info simple_inner_loop_info = NULL;
bool allow_double_reduc = true;
+ if (!stmt_vec_info_vec.exists ())
+ init_stmt_vec_info_vec ();
+
simple_loop_info = vect_analyze_loop_form (loop);
if (simple_loop_info == NULL)
return;
@@ -2453,9 +2461,16 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
destroy_loop_vec_info (simple_loop_info, true);
destroy_loop_vec_info (simple_inner_loop_info, true);
+ /* Release the claim on gimple_uid. */
+ free_stmt_vec_info_vec ();
+
With the src/libgomp/testsuite/libgomp.c/pr46886.c testcase, compiled in
addition with -ftree-vectorize, I ran into an ICE:
...
src/libgomp/testsuite/libgomp.c/pr46886.c:8:5: internal compiler error:
in init_stmt_vec_info_vec, at tree-vect-stmts.c:8250
int foo (void)
^~~
0x1196082 init_stmt_vec_info_vec()
src/gcc/tree-vect-stmts.c:8250
0x11c3ed4 vectorize_loops()
src/gcc/tree-vectorizer.c:510
0x10a7ea5 execute
src/gcc/tree-ssa-loop.c:276
...
The ICE is caused by the fact that init_stmt_vec_info_vec is called at
the start of vectorize_loops, while stmt_vec_info_vec is not empty. I
traced this back to gather_scalar_reduction, where we call
init_stmt_vec_info_vec, but we skip free_stmt_vec_info_vec if we take
the early-out for simple_loop_info == NULL.
This patch fixes the ICE by making sure we always call
free_stmt_vec_info_vec in gather_scalar_reduction.
Passes cc1/f951 rebuild and autopar testing.
OK for stage3 trunk if bootstrap and regtest succeeds?
Thanks,
- Tom
Always call free_stmt_vec_info_vec in gather_scalar_reductions
2015-11-20 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/68460
* tree-parloops.c (gather_scalar_reductions): Also call
free_stmt_vec_info_vec if simple_loop_info == NULL.
* gcc.dg/autopar/pr68460.c: New test.
---
gcc/testsuite/gcc.dg/autopar/pr68460.c | 35 ++++++++++++++++++++++++++++++++++
gcc/tree-parloops.c | 6 +++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/gcc.dg/autopar/pr68460.c b/gcc/testsuite/gcc.dg/autopar/pr68460.c
new file mode 100644
index 0000000..0c00065
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/pr68460.c
@@ -0,0 +1,35 @@
+/* { dg-do "compile" } */
+/* { dg-options "-O -ftree-parallelize-loops=2 -ftree-vectorize -fno-tree-ch -fno-tree-dominator-opts" } */
+
+void abort (void);
+
+int d[1024], e[1024];
+
+int
+foo (void)
+{
+ int s = 0;
+ int i;
+
+ for (i = 0; i < 1024; i++)
+ s += d[i] - e[i];
+
+ return s;
+}
+
+int
+main ()
+{
+ int i;
+
+ for (i = 0; i < 1024; i++)
+ {
+ d[i] = i * 2;
+ e[i] = i;
+ }
+
+ if (foo () != 1023 * 1024 / 2)
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index 8d7912d..85cc78d 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2433,7 +2433,7 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
simple_loop_info = vect_analyze_loop_form (loop);
if (simple_loop_info == NULL)
- return;
+ goto gather_done;
for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
{
@@ -2492,9 +2492,13 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
destroy_loop_vec_info (simple_loop_info, true);
destroy_loop_vec_info (simple_inner_loop_info, true);
+ gather_done:
/* Release the claim on gimple_uid. */
free_stmt_vec_info_vec ();
+ if (reduction_list->elements () == 0)
+ return;
+
/* As gimple_uid is used by the vectorizer in between vect_analyze_loop_form
and free_stmt_vec_info_vec, we can set gimple_uid of reduc_phi stmts only
now. */