diff mbox

[i386] : Add support of delegitimize of UNSPEC_PCREL plus displacement

Message ID CAEwic4YWD-zow7f6_djO0XazbLiZH4LFnOgJzJBg1w193HCYrw@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Feb. 23, 2012, 4:38 p.m. UTC
Hi,

This patch adds a missing nit about delegitimize of CONST
(UNSPEC_PCREL + displacement).
Some testcases - like gcc.c-torture/execute/ 930930-1.c - were failing due this.

ChangeLog

2012-02-23  Kai Tietz  <ktietz@redhat.com>

	* config/i386/i386.c (ix86_delegitimize_address): Handle
	UNSPEC_PCREL plus displacement.

Regression tested for x86_64-w64-mingw32, and
x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Comments

Jakub Jelinek Feb. 23, 2012, 4:41 p.m. UTC | #1
On Thu, Feb 23, 2012 at 05:38:37PM +0100, Kai Tietz wrote:
> --- config/i386/i386.c	(revision 184486)
> +++ config/i386/i386.c	(working copy)
> @@ -13241,6 +13241,22 @@
> 
>    if (TARGET_64BIT)
>      {
> +      if (GET_CODE (x) == CONST
> +          && GET_CODE (XEXP (x, 0)) == PLUS
> +          && GET_MODE (XEXP (x, 0)) == Pmode
> +          && CONST_INT_P (XEXP (XEXP (x, 0), 1))
> +          && GET_CODE (XEXP (XEXP (x, 0), 0)) == UNSPEC
> +          && XINT (XEXP (XEXP (x, 0), 0), 1) == UNSPEC_PCREL)
> +        {
> +	  rtx x2 = XVECEXP (XEXP (XEXP (x, 0), 0), 0, 0);
> +	  x = gen_rtx_PLUS (Pmode, XEXP (XEXP (x, 0), 1), x2);
> +	  if (MEM_P (orig_x))
> +	    x = replace_equiv_address_nv (orig_x, x);
> +	  return x;
> +	}
> +      if (GET_CODE (x) == UNSPEC
> +          && XINT (x, 1) == UNSPEC_PCREL)
> +        return XVECEXP (x, 0, 0);

Here you don't need the MEM_P (orig_x) handling?
That's strange.

>        if (GET_CODE (x) != CONST
>  	  || GET_CODE (XEXP (x, 0)) != UNSPEC
>  	  || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL

	Jakub
Kai Tietz Feb. 23, 2012, 4:58 p.m. UTC | #2
2012/2/23 Jakub Jelinek <jakub@redhat.com>:
> On Thu, Feb 23, 2012 at 05:38:37PM +0100, Kai Tietz wrote:
>> --- config/i386/i386.c        (revision 184486)
>> +++ config/i386/i386.c        (working copy)
>> @@ -13241,6 +13241,22 @@
>>
>>    if (TARGET_64BIT)
>>      {
>> +      if (GET_CODE (x) == CONST
>> +          && GET_CODE (XEXP (x, 0)) == PLUS
>> +          && GET_MODE (XEXP (x, 0)) == Pmode
>> +          && CONST_INT_P (XEXP (XEXP (x, 0), 1))
>> +          && GET_CODE (XEXP (XEXP (x, 0), 0)) == UNSPEC
>> +          && XINT (XEXP (XEXP (x, 0), 0), 1) == UNSPEC_PCREL)
>> +        {
>> +       rtx x2 = XVECEXP (XEXP (XEXP (x, 0), 0), 0, 0);
>> +       x = gen_rtx_PLUS (Pmode, XEXP (XEXP (x, 0), 1), x2);
>> +       if (MEM_P (orig_x))
>> +         x = replace_equiv_address_nv (orig_x, x);
>> +       return x;
>> +     }
>> +      if (GET_CODE (x) == UNSPEC
>> +          && XINT (x, 1) == UNSPEC_PCREL)
>> +        return XVECEXP (x, 0, 0);
>
> Here you don't need the MEM_P (orig_x) handling?
> That's strange.
>
>>        if (GET_CODE (x) != CONST
>>         || GET_CODE (XEXP (x, 0)) != UNSPEC
>>         || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
>
>        Jakub

Hmm, those three lines are not necessary.  Sorry, I missed to remove
them from my patch.
>> +      if (GET_CODE (x) == UNSPEC
>> +          && XINT (x, 1) == UNSPEC_PCREL)
>> +        return XVECEXP (x, 0, 0);

  But indeed the mem-case isn't necessary here, as this pattern never matches.

I will retest without those three-lines and post updated patch then.

Regards,
Kai
diff mbox

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 184486)
+++ config/i386/i386.c	(working copy)
@@ -13241,6 +13241,22 @@ 

   if (TARGET_64BIT)
     {
+      if (GET_CODE (x) == CONST
+          && GET_CODE (XEXP (x, 0)) == PLUS
+          && GET_MODE (XEXP (x, 0)) == Pmode
+          && CONST_INT_P (XEXP (XEXP (x, 0), 1))
+          && GET_CODE (XEXP (XEXP (x, 0), 0)) == UNSPEC
+          && XINT (XEXP (XEXP (x, 0), 0), 1) == UNSPEC_PCREL)
+        {
+	  rtx x2 = XVECEXP (XEXP (XEXP (x, 0), 0), 0, 0);
+	  x = gen_rtx_PLUS (Pmode, XEXP (XEXP (x, 0), 1), x2);
+	  if (MEM_P (orig_x))
+	    x = replace_equiv_address_nv (orig_x, x);
+	  return x;
+	}
+      if (GET_CODE (x) == UNSPEC
+          && XINT (x, 1) == UNSPEC_PCREL)
+        return XVECEXP (x, 0, 0);
       if (GET_CODE (x) != CONST
 	  || GET_CODE (XEXP (x, 0)) != UNSPEC
 	  || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL