This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] PR23046


On Tuesday 08 November 2005 01:44, James A. Morrison wrote:
>  Hi,
>
>   This patch simply works around the ICE in vrp.  I've bootstrapped and
> regtested this patch on ia64-linux.  Ok for mainline?

Actually, having looked at the problem again, we are better off not 
asserting an impossible predicate.  Saves us the trouble and doesn't brush 
over other problems that may cause us to create paradoxical ranges.

Bootstrap/test in progress.


2005-11-08  James A. Morrison  <phython@gcc.gnu.org>
	    Diego Novillo  <dnovillo@redhat.com>

	PR 23046
	* tree-vrp.c (register_edge_assert_for): Do not register
	always-false predicates.

testsuite/

	PR 23046
	* g++.dg/tree-ssa/pr23046.C: New test.

Index: tree-vrp.c
===================================================================
--- tree-vrp.c	(revision 106635)
+++ tree-vrp.c	(working copy)
@@ -2504,6 +2504,24 @@ register_edge_assert_for (tree name, edg
 	     need to invert the sign comparison.  */
 	  if (is_else_edge)
 	    comp_code = invert_tree_comparison (comp_code, 0);
+
+	  /* Do not register always-false predicates.  FIXME, this
+	     works around a limitation in fold() when dealing with
+	     enumerations.  Given 'enum { N1, N2 } x;', fold will not
+	     fold 'if (x > N2)' to 'if (0)'.  */
+	  if ((comp_code == GT_EXPR || comp_code == LT_EXPR)
+	      && (INTEGRAL_TYPE_P (TREE_TYPE (val))
+		  || SCALAR_FLOAT_TYPE_P (TREE_TYPE (val))))
+	    {
+	      tree min = TYPE_MIN_VALUE (TREE_TYPE (val));
+	      tree max = TYPE_MAX_VALUE (TREE_TYPE (val));
+
+	      if (comp_code == GT_EXPR && compare_values (val, max) == 0)
+		return false;
+
+	      if (comp_code == LT_EXPR && compare_values (val, min) == 0)
+		return false;
+	    }
 	}
     }
   else
Index: testsuite/g++.dg/tree-ssa/pr23046.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr23046.C	(revision 0)
+++ testsuite/g++.dg/tree-ssa/pr23046.C	(revision 0)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+enum eumtype { ENUM1, ENUM2 };
+void g(const eumtype kind );
+void f(long i);
+void g(const eumtype kind)
+{
+  if ((kind != ENUM1) && (kind != ENUM2))
+    f(kind);
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]