diff mbox

Fix hppa-* --enable-checking=release bootstrap (PR bootstrap/48161)

Message ID 20110317200743.GX30899@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 17, 2011, 8:07 p.m. UTC
On Thu, Mar 17, 2011 at 12:54:44PM -0700, Richard Henderson wrote:
> On 03/17/2011 11:46 AM, Jakub Jelinek wrote:
> > -	result = gen_rtx_PLUS (tmode, result, tmp);
> > +	{
> > +	  if (swap_commutative_operands_p (result, tmp))
> > +	    result = gen_rtx_PLUS (tmode, tmp, result);
> > +	  else
> > +	    result = gen_rtx_PLUS (tmode, result, tmp);
> 
> Hum.  What about simplify_gen_binary (PLUS, tmode, result, tmp)
> which will also do the swap?

You're right, that will magically handle even the hypothetical
case when both result and tmp will be constants and handles
even better this exact case (where result is (const_int 0) ).

The following fixes the testcase in cross to hppa-* as well.
I'll bootstrap/regtest it momentarily, ok if it passes?

2011-03-17  Richard Henderson  <rth@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/48161
	* expr.c (expand_expr_addr_expr_1): Use simplify_gen_binary
	instead of gen_rtx_PLUS if EXPAND_SUM or EXPAND_INITIALIZER.

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



	Jakub

Comments

Jakub Jelinek March 17, 2011, 10:38 p.m. UTC | #1
On Thu, Mar 17, 2011 at 09:07:43PM +0100, Jakub Jelinek wrote:
> The following fixes the testcase in cross to hppa-* as well.
> I'll bootstrap/regtest it momentarily, ok if it passes?

Now bootstrapped/regtested on x86_64-linux and i686-linux.

> 2011-03-17  Richard Henderson  <rth@redhat.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR bootstrap/48161
> 	* expr.c (expand_expr_addr_expr_1): Use simplify_gen_binary
> 	instead of gen_rtx_PLUS if EXPAND_SUM or EXPAND_INITIALIZER.
> 
> 	* gcc.c-torture/compile/pr48161.c: New test.
> 
> --- gcc/expr.c.jj	2011-03-14 14:12:15.000000000 +0100
> +++ gcc/expr.c	2011-03-17 16:49:01.000000000 +0100
> @@ -6971,7 +6971,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t
>        tmp = convert_memory_address_addr_space (tmode, tmp, as);
>  
>        if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
> -	result = gen_rtx_PLUS (tmode, result, tmp);
> +	result = simplify_gen_binary (PLUS, tmode, result, tmp);
>        else
>  	{
>  	  subtarget = bitpos ? NULL_RTX : target;
> --- gcc/testsuite/gcc.c-torture/compile/pr48161.c.jj	2011-03-09 16:32:56.855000001 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr48161.c	2011-03-17 17:20:34.000000000 +0100

	Jakub
Richard Biener March 18, 2011, 8:30 a.m. UTC | #2
On Thu, Mar 17, 2011 at 11:38 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Mar 17, 2011 at 09:07:43PM +0100, Jakub Jelinek wrote:
>> The following fixes the testcase in cross to hppa-* as well.
>> I'll bootstrap/regtest it momentarily, ok if it passes?
>
> Now bootstrapped/regtested on x86_64-linux and i686-linux.

Ok.

Thanks,
Richard.

>> 2011-03-17  Richard Henderson  <rth@redhat.com>
>>           Jakub Jelinek  <jakub@redhat.com>
>>
>>       PR bootstrap/48161
>>       * expr.c (expand_expr_addr_expr_1): Use simplify_gen_binary
>>       instead of gen_rtx_PLUS if EXPAND_SUM or EXPAND_INITIALIZER.
>>
>>       * gcc.c-torture/compile/pr48161.c: New test.
>>
>> --- gcc/expr.c.jj     2011-03-14 14:12:15.000000000 +0100
>> +++ gcc/expr.c        2011-03-17 16:49:01.000000000 +0100
>> @@ -6971,7 +6971,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t
>>        tmp = convert_memory_address_addr_space (tmode, tmp, as);
>>
>>        if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
>> -     result = gen_rtx_PLUS (tmode, result, tmp);
>> +     result = simplify_gen_binary (PLUS, tmode, result, tmp);
>>        else
>>       {
>>         subtarget = bitpos ? NULL_RTX : target;
>> --- gcc/testsuite/gcc.c-torture/compile/pr48161.c.jj  2011-03-09 16:32:56.855000001 +0100
>> +++ gcc/testsuite/gcc.c-torture/compile/pr48161.c     2011-03-17 17:20:34.000000000 +0100
>
>        Jakub
>
diff mbox

Patch

--- gcc/expr.c.jj	2011-03-14 14:12:15.000000000 +0100
+++ gcc/expr.c	2011-03-17 16:49:01.000000000 +0100
@@ -6971,7 +6971,7 @@  expand_expr_addr_expr_1 (tree exp, rtx t
       tmp = convert_memory_address_addr_space (tmode, tmp, as);
 
       if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER)
-	result = gen_rtx_PLUS (tmode, result, tmp);
+	result = simplify_gen_binary (PLUS, tmode, result, tmp);
       else
 	{
 	  subtarget = bitpos ? NULL_RTX : target;
--- gcc/testsuite/gcc.c-torture/compile/pr48161.c.jj	2011-03-09 16:32:56.855000001 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr48161.c	2011-03-17 17:20:34.000000000 +0100
@@ -0,0 +1,24 @@ 
+/* PR bootstrap/48161 */
+
+struct T { int u; };
+struct G { int l; int t; int r; };
+struct V { struct G v[10]; };
+struct { struct V b; } *h;
+void bar (void);
+
+struct G *
+baz (struct V *x, unsigned y)
+{
+  return &x->v[y];
+}
+
+int
+foo (struct T *x, struct T *y)
+{
+  if ((baz (&h->b, y->u)->t ? baz (&h->b, y->u)->t : 0)
+      - baz (h ? &h->b : 0, x->u)->r
+      - (baz (h ? &h->b : 0, x->u)->t > 0 ? 5 : 0))
+    return 1;
+  bar ();
+  return 0;
+}