diff mbox

Build failure (Re: [PATCH] Make VRP optimize useless conversions)

Message ID alpine.LNX.2.00.1107131017510.810@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener July 13, 2011, 8:28 a.m. UTC
On Tue, 12 Jul 2011, Ulrich Weigand wrote:

> Richard Guenther wrote:
> 
> > 2011-07-11  Richard Guenther  <rguenther@suse.de>
> > 
> > 	* tree-vrp.c (simplify_conversion_using_ranges): Manually
> > 	translate the source value-range through the conversion chain.
> 
> This causes a build failure in cachemgr.c on spu-elf.  A slightly
> modified simplified test case also fails on i386-linux:
> 
> void *
> test (unsigned long long x, unsigned long long y)
> {
>   return (void *) (unsigned int) (x / y);
> }
> 
> compiled with -O2 results in:
> 
> test.i: In function 'test':
> test.i:3:1: error: invalid types in nop conversion
> void *
> long long unsigned int
> D.1962_5 = (void *) D.1963_3;
> 
> test.i:3:1: internal compiler error: verify_gimple failed
> 
> Any thoughts?

Fix in testing.

Richard.

2011-07-13  Richard Guenther  <rguenther@suse.de>

	* tree-vrp.c (simplify_conversion_using_ranges): Make sure
	the final type is integral.

	* gcc.dg/torture/20110713-1.c: New testcase.

Comments

H.J. Lu July 13, 2011, 1:03 p.m. UTC | #1
On Wed, Jul 13, 2011 at 1:28 AM, Richard Guenther <rguenther@suse.de> wrote:
> On Tue, 12 Jul 2011, Ulrich Weigand wrote:
>
>> Richard Guenther wrote:
>>
>> > 2011-07-11  Richard Guenther  <rguenther@suse.de>
>> >
>> >     * tree-vrp.c (simplify_conversion_using_ranges): Manually
>> >     translate the source value-range through the conversion chain.
>>
>> This causes a build failure in cachemgr.c on spu-elf.  A slightly
>> modified simplified test case also fails on i386-linux:
>>
>> void *
>> test (unsigned long long x, unsigned long long y)
>> {
>>   return (void *) (unsigned int) (x / y);
>> }
>>
>> compiled with -O2 results in:
>>
>> test.i: In function 'test':
>> test.i:3:1: error: invalid types in nop conversion
>> void *
>> long long unsigned int
>> D.1962_5 = (void *) D.1963_3;
>>
>> test.i:3:1: internal compiler error: verify_gimple failed
>>
>> Any thoughts?
>
> Fix in testing.
>
> Richard.
>
> 2011-07-13  Richard Guenther  <rguenther@suse.de>
>
>        * tree-vrp.c (simplify_conversion_using_ranges): Make sure
>        the final type is integral.
>
>        * gcc.dg/torture/20110713-1.c: New testcase.
>
> Index: gcc/tree-vrp.c
> ===================================================================
> --- gcc/tree-vrp.c      (revision 176224)
> +++ gcc/tree-vrp.c      (working copy)
> @@ -7353,6 +7353,8 @@ simplify_conversion_using_ranges (gimple
>   double_int innermin, innermax, middlemin, middlemax;
>
>   finaltype = TREE_TYPE (gimple_assign_lhs (stmt));
> +  if (!INTEGRAL_TYPE_P (finaltype))
> +    return false;
>   middleop = gimple_assign_rhs1 (stmt);
>   def_stmt = SSA_NAME_DEF_STMT (middleop);
>   if (!is_gimple_assign (def_stmt)
> Index: gcc/testsuite/gcc.dg/torture/20110713-1.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/torture/20110713-1.c   (revision 0)
> +++ gcc/testsuite/gcc.dg/torture/20110713-1.c   (revision 0)
> @@ -0,0 +1,8 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target ilp32 } */
> +
> +void *
> +test (unsigned long long x, unsigned long long y)
> +{
> +    return (void *) (unsigned int) (x / y);
> +}
>

This also fixed:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49731
diff mbox

Patch

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 176224)
+++ gcc/tree-vrp.c	(working copy)
@@ -7353,6 +7353,8 @@  simplify_conversion_using_ranges (gimple
   double_int innermin, innermax, middlemin, middlemax;
 
   finaltype = TREE_TYPE (gimple_assign_lhs (stmt));
+  if (!INTEGRAL_TYPE_P (finaltype))
+    return false;
   middleop = gimple_assign_rhs1 (stmt);
   def_stmt = SSA_NAME_DEF_STMT (middleop);
   if (!is_gimple_assign (def_stmt)
Index: gcc/testsuite/gcc.dg/torture/20110713-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/20110713-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/20110713-1.c	(revision 0)
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ilp32 } */
+
+void *
+test (unsigned long long x, unsigned long long y)
+{
+    return (void *) (unsigned int) (x / y);
+}