public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR60849
@ 2014-04-17  8:07 Richard Biener
  2014-04-17 11:18 ` Marc Glisse
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2014-04-17  8:07 UTC (permalink / raw)
  To: gcc-patches


This fixes PR60849 by properly rejecting non-boolean typed
comparisons from valid_gimple_rhs_p so they go through the
gimplification paths.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2014-04-16  Richard Biener  <rguenther@suse.de>

	PR middle-end/60849
	* tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective
	boolean results for comparisons.

	* g++.dg/opt/pr60849.C: New testcase.

Index: gcc/tree-ssa-propagate.c
===================================================================
--- gcc/tree-ssa-propagate.c	(revision 209423)
+++ gcc/tree-ssa-propagate.c	(working copy)
@@ -571,8 +571,14 @@ valid_gimple_rhs_p (tree expr)
       /* All constants are ok.  */
       break;
 
-    case tcc_binary:
     case tcc_comparison:
+      if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
+	  || (TREE_CODE (TREE_TYPE (expr)) != BOOLEAN_TYPE
+	      && TYPE_PRECISION (TREE_TYPE (expr)) != 1))
+	return false;
+
+      /* Fallthru.  */
+    case tcc_binary:
       if (!is_gimple_val (TREE_OPERAND (expr, 0))
 	  || !is_gimple_val (TREE_OPERAND (expr, 1)))
 	return false;
Index: gcc/testsuite/g++.dg/opt/pr60849.C
===================================================================
--- gcc/testsuite/g++.dg/opt/pr60849.C	(revision 0)
+++ gcc/testsuite/g++.dg/opt/pr60849.C	(working copy)
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-O2" }
+
+int g;
+
+extern "C" int isnan ();
+
+void foo(float a) {
+  int (*xx)(...);
+  xx = isnan;
+  if (xx(a))
+    g++;
+}

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

* Re: [PATCH] Fix PR60849
  2014-04-17  8:07 [PATCH] Fix PR60849 Richard Biener
@ 2014-04-17 11:18 ` Marc Glisse
  2014-04-17 11:39   ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Glisse @ 2014-04-17 11:18 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Thu, 17 Apr 2014, Richard Biener wrote:

> This fixes PR60849 by properly rejecting non-boolean typed
> comparisons from valid_gimple_rhs_p so they go through the
> gimplification paths.

Could you also accept vector comparisons please?

-- 
Marc Glisse

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

* Re: [PATCH] Fix PR60849
  2014-04-17 11:18 ` Marc Glisse
@ 2014-04-17 11:39   ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2014-04-17 11:39 UTC (permalink / raw)
  To: Marc Glisse; +Cc: gcc-patches

On Thu, 17 Apr 2014, Marc Glisse wrote:

> On Thu, 17 Apr 2014, Richard Biener wrote:
> 
> > This fixes PR60849 by properly rejecting non-boolean typed
> > comparisons from valid_gimple_rhs_p so they go through the
> > gimplification paths.
> 
> Could you also accept vector comparisons please?

Sure.  Testing in progress.

Richard.

2014-04-17  Richard Biener  <rguenther@suse.de>

	PR middle-end/60849
	* tree-ssa-propagate.c (valid_gimple_rhs_p): Allow vector
	comparison results and add clarifying comment.

Index: gcc/tree-ssa-propagate.c
===================================================================
--- gcc/tree-ssa-propagate.c	(revision 209469)
+++ gcc/tree-ssa-propagate.c	(working copy)
@@ -572,9 +572,13 @@ valid_gimple_rhs_p (tree expr)
       break;
 
     case tcc_comparison:
-      if (!INTEGRAL_TYPE_P (TREE_TYPE (expr))
-	  || (TREE_CODE (TREE_TYPE (expr)) != BOOLEAN_TYPE
-	      && TYPE_PRECISION (TREE_TYPE (expr)) != 1))
+      /* GENERIC allows comparisons with non-boolean types, reject
+         those for GIMPLE.  Let vector-typed comparisons pass - rules
+	 for GENERIC and GIMPLE are the same here.  */
+      if (!(INTEGRAL_TYPE_P (TREE_TYPE (expr))
+	    && (TREE_CODE (TREE_TYPE (expr)) == BOOLEAN_TYPE
+		|| TYPE_PRECISION (TREE_TYPE (expr)) == 1))
+	  && TREE_CODE (TREE_TYPE (expr)) != VECTOR_TYPE)
 	return false;
 
       /* Fallthru.  */

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

end of thread, other threads:[~2014-04-17 11:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-17  8:07 [PATCH] Fix PR60849 Richard Biener
2014-04-17 11:18 ` Marc Glisse
2014-04-17 11:39   ` 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).