public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Committed, PR69108] Handle case that outer phi res is not used in a phi in gather_scalar_reductions
@ 2016-01-11  9:30 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2016-01-11  9:30 UTC (permalink / raw)
  To: gcc-patches, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 880 bytes --]

Hi,

when compiling interchange-2.c with ftree-parallelize-loops=2 we run 
into an ICE:
...
$ gcc -O2 src/gcc/testsuite/gcc.dg/graphite/interchange-2.c -S 
-ftree-parallelize-loops=2
interchange-2.c: In function ‘foo.constprop’:
interchange-2.c:13:1: internal compiler error: in as_a, at is-a.h:192
  foo (int N, int *res)
...


The problem is in the double reduction handling code added in r226300:
...
          bool single_use_p = single_imm_use (res, &use_p, &inner_stmt);
          gcc_assert (single_use_p);
          gphi *inner_phi = as_a <gphi *> (inner_stmt);
...

The code assumes that inner_stmt is a phi, but the ICE shows that it's 
possible that that's not the case.


The patch fixes the problem conservatively by testing if inner_stmt is a 
PHI, and handling the non-phi case.

Bootstrapped and reg-tested on x86_64.

Committed to trunk.

Thanks,
- Tom

[-- Attachment #2: 0001-Handle-case-that-outer-phi-res-is-not-used-in-a-phi-in-gather_scalar_reductions.patch --]
[-- Type: text/x-patch, Size: 1332 bytes --]

Handle case that outer phi res is not used in a phi in gather_scalar_reductions

2016-01-07  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/69108
	* tree-parloops.c (gather_scalar_reductions): Handle case that outer phi
	res is not used in a phi.

	* gcc.dg/autopar/pr69108.c: New test.

---
 gcc/testsuite/gcc.dg/autopar/pr69108.c | 4 ++++
 gcc/tree-parloops.c                    | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/autopar/pr69108.c b/gcc/testsuite/gcc.dg/autopar/pr69108.c
new file mode 100644
index 0000000..39fc07e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/autopar/pr69108.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-parallelize-loops=2" } */
+
+#include "../graphite/interchange-2.c"
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c
index e05cc47..d683704 100644
--- a/gcc/tree-parloops.c
+++ b/gcc/tree-parloops.c
@@ -2474,6 +2474,8 @@ gather_scalar_reductions (loop_p loop, reduction_info_table_type *reduction_list
 	  gimple *inner_stmt;
 	  bool single_use_p = single_imm_use (res, &use_p, &inner_stmt);
 	  gcc_assert (single_use_p);
+	  if (gimple_code (inner_stmt) != GIMPLE_PHI)
+	    continue;
 	  gphi *inner_phi = as_a <gphi *> (inner_stmt);
 	  if (simple_iv (loop->inner, loop->inner, PHI_RESULT (inner_phi),
 			 &iv, true))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-11  9:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11  9:30 [Committed, PR69108] Handle case that outer phi res is not used in a phi in gather_scalar_reductions Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).