Patchwork Fix simplify_cond_using_ranges ICE (PR tree-optimization/57331)

login
register
mail settings
Submitter Jakub Jelinek
Date May 21, 2013, 3:03 p.m.
Message ID <20130521150318.GX1377@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/245319/
State New
Headers show

Comments

Jakub Jelinek - May 21, 2013, 3:03 p.m.
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.


	Jakub
Jeff Law - May 21, 2013, 3:06 p.m.
On 05/21/2013 09:03 AM, Jakub Jelinek wrote:
> 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.
Ok.  Sorry for the breakage.

jeff

Patch

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