public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR68809] Fix same_close_phi_node
@ 2016-03-16  7:31 Tom de Vries
  2016-03-16  8:33 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2016-03-16  7:31 UTC (permalink / raw)
  To: Richard Biener, Sebastian Pop; +Cc: GCC Patches

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

Hi,

this patch fixes graphite PR68809, a 6 regression.

The problem we run into is that we return true in same_close_phi_node 
for two single-argument phis, one with an int 0 argument, and one with a 
char 0 argument:
...
   _1 = PHI <(int)0>
   _2 = PHI <(char)0>
...
The result types of the two phis are not the same though.

So when we replace uses of _1 by uses of _2 in 
remove_duplicate_close_phi, we introduce type errors, which causes an 
ICE during gimple verification.

The patch fixes this by testing for equality of the result type of the 
phis in same_close_phi_node.

Bootstrapped and reg-tested on x86_64.

OK for stage4 trunk?

Thanks,
- Tom

[-- Attachment #2: 0001-Fix-same_close_phi_node.patch --]
[-- Type: text/x-patch, Size: 2409 bytes --]

Fix same_close_phi_node

2016-03-15  Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/68809
	* graphite-scop-detection.c (same_close_phi_node): Test if result types
	are the same.

	* gcc.dg/graphite/pr68809-2.c: New test.
	* gcc.dg/graphite/pr68809.c: New test.

---
 gcc/graphite-scop-detection.c             |  6 ++++--
 gcc/testsuite/gcc.dg/graphite/pr68809-2.c | 27 +++++++++++++++++++++++++++
 gcc/testsuite/gcc.dg/graphite/pr68809.c   | 28 ++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c
index 03b1c49..9161cb7 100644
--- a/gcc/graphite-scop-detection.c
+++ b/gcc/graphite-scop-detection.c
@@ -273,8 +273,10 @@ trivially_empty_bb_p (basic_block bb)
 static inline bool
 same_close_phi_node (gphi *p1, gphi *p2)
 {
-  return operand_equal_p (gimple_phi_arg_def (p1, 0),
-			  gimple_phi_arg_def (p2, 0), 0);
+  return ((TREE_TYPE (gimple_phi_result (p1))
+	   == TREE_TYPE (gimple_phi_result (p2)))
+	  && operand_equal_p (gimple_phi_arg_def (p1, 0),
+			      gimple_phi_arg_def (p2, 0), 0));
 }
 
 static void make_close_phi_nodes_unique (basic_block bb);
diff --git a/gcc/testsuite/gcc.dg/graphite/pr68809-2.c b/gcc/testsuite/gcc.dg/graphite/pr68809-2.c
new file mode 100644
index 0000000..e6639b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr68809-2.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int ae, vs, gf;
+char ue;
+
+void
+kc (char);
+
+void
+pm (void)
+{
+  unsigned int v9;
+  int td = (gf != 0);
+  while (vs)
+    {
+      kc (ue);
+      for (ae = 0; ae < 70; ++ae)
+	{
+	}
+      ae &= 4;
+      ae ^ td && ((ue = 0) != 0);
+      ++vs;
+    }
+  v9 = ue + 1;
+  ue - v9 && ((ue = 0) != 0);
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr68809.c b/gcc/testsuite/gcc.dg/graphite/pr68809.c
new file mode 100644
index 0000000..1d75841
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/pr68809.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize" } */
+
+int ae, vs;
+char ue;
+
+void
+kc (char);
+
+void
+pm (void)
+{
+  unsigned int v9;
+  int gf = 0;
+  vs = 1;
+  while (vs)
+    {
+      gf -= ue;
+      kc (ue);
+      for (ae = 0; ae < 70; ++ae)
+	{
+	}
+      ae &= 4;
+      ae ^ (gf != 0) && ((ue = 0) != 0);
+    }
+  v9 = ue + 1;
+  ue - v9 && ((ue = 0) != 0);
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR68809] Fix same_close_phi_node
  2016-03-16  7:31 [PATCH, PR68809] Fix same_close_phi_node Tom de Vries
@ 2016-03-16  8:33 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-03-16  8:33 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Sebastian Pop, GCC Patches

On Wed, 16 Mar 2016, Tom de Vries wrote:

> Hi,
> 
> this patch fixes graphite PR68809, a 6 regression.
> 
> The problem we run into is that we return true in same_close_phi_node for two
> single-argument phis, one with an int 0 argument, and one with a char 0
> argument:
> ...
>   _1 = PHI <(int)0>
>   _2 = PHI <(char)0>
> ...
> The result types of the two phis are not the same though.
> 
> So when we replace uses of _1 by uses of _2 in remove_duplicate_close_phi, we
> introduce type errors, which causes an ICE during gimple verification.
> 
> The patch fixes this by testing for equality of the result type of the phis in
> same_close_phi_node.
> 
> Bootstrapped and reg-tested on x86_64.
> 
> OK for stage4 trunk?

Please use types_compatible_p () rather than strict equality.

Ok with that change.

Richard.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-16  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-16  7:31 [PATCH, PR68809] Fix same_close_phi_node Tom de Vries
2016-03-16  8:33 ` Richard Biener

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).