diff mbox

Fix PR60849

Message ID alpine.LSU.2.11.1404171004000.3272@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener April 17, 2014, 8:05 a.m. UTC
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.

Comments

Marc Glisse April 17, 2014, 11:04 a.m. UTC | #1
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?
diff mbox

Patch

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++;
+}