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]

[PATCH] Fix simplify_cond_using_ranges ICE (PR tree-optimization/57331)


Hi!

int_fits_type_p ICEs if the second argument is pointer type (those don't
have TYPE_MIN_VALUE/TYPE_MAX_VALUE).  Fixed thusly, bootstrapped/regtested
on x86_64-linux and i686-linux, ok for trunk?

2013-05-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/57331
	* tree-vrp.c (simplify_cond_using_ranges): Don't optimize
	comparison of conversion from pointer type to integral type
	with integer.

	* gcc.c-torture/compile/pr57331.c: New test.

--- gcc/tree-vrp.c.jj	2013-05-04 14:35:01.000000000 +0200
+++ gcc/tree-vrp.c	2013-05-21 12:07:33.382917422 +0200
@@ -8661,7 +8661,8 @@ simplify_cond_using_ranges (gimple stmt)
 
       innerop = gimple_assign_rhs1 (def_stmt);
 
-      if (TREE_CODE (innerop) == SSA_NAME)
+      if (TREE_CODE (innerop) == SSA_NAME
+	  && !POINTER_TYPE_P (TREE_TYPE (innerop)))
 	{
 	  value_range_t *vr = get_value_range (innerop);
 
--- gcc/testsuite/gcc.c-torture/compile/pr57331.c.jj	2013-05-21 12:08:11.859697048 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr57331.c	2013-05-21 12:06:27.000000000 +0200
@@ -0,0 +1,11 @@
+/* PR tree-optimization/57331 */
+
+int
+foo (int x)
+{
+  void *p = x ? (void *) 1 : (void *) 0;
+  __INTPTR_TYPE__ b = (__INTPTR_TYPE__) p;
+  if (b)
+    return 0;
+  return 1;
+}

	Jakub


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