diff mbox

PATCH: PR rtl-optimization/49504: Invalid optimization for Pmode != ptr_mode

Message ID BANLkTi=QjfaQz6E8KObg9Cois7fg734ksQ@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu June 24, 2011, 2:17 p.m. UTC
On Fri, Jun 24, 2011 at 7:07 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> I compared x32 glibc built with the old x32 gcc against x32 glibc built
>> with this patch and
>>
>> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00913.html
>>
>> reverted, the new glibc is little smaller:
>>
>> New:
>>
>> [hjl@gnu-33 build-x86_64-linux]$ size libc.so
>>    text          data     bss     dec     hex filename
>> 1537648         10076   12944 1560668  17d05c libc.so
>> [hjl@gnu-33 build-x86_64-linux]$
>>
>> Old:
>>
>> [hjl@gnu-33 build-x86_64-linux.old]$ size libc.so
>>    text          data     bss     dec     hex filename
>> 1538968         10076   12944 1561988  17d584 libc.so
>> [hjl@gnu-33 build-x86_64-linux.old]$
>>
>> I looked at assembly codes.  The new one is better.
>> I will check it in.
>
> OK, but remove the equivalent code in num_sign_bit_copies1 then, otherwise
> someone in a couple of years from now will adapt it to nonzero_bits1 and we
> will be back to square one.
>

I am testing this patch on x32 branch.  I will compare glibc binaries before and
after.

Thanks.

Comments

H.J. Lu June 24, 2011, 3:24 p.m. UTC | #1
On Fri, Jun 24, 2011 at 7:17 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Jun 24, 2011 at 7:07 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> I compared x32 glibc built with the old x32 gcc against x32 glibc built
>>> with this patch and
>>>
>>> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00913.html
>>>
>>> reverted, the new glibc is little smaller:
>>>
>>> New:
>>>
>>> [hjl@gnu-33 build-x86_64-linux]$ size libc.so
>>>    text          data     bss     dec     hex filename
>>> 1537648         10076   12944 1560668  17d05c libc.so
>>> [hjl@gnu-33 build-x86_64-linux]$
>>>
>>> Old:
>>>
>>> [hjl@gnu-33 build-x86_64-linux.old]$ size libc.so
>>>    text          data     bss     dec     hex filename
>>> 1538968         10076   12944 1561988  17d584 libc.so
>>> [hjl@gnu-33 build-x86_64-linux.old]$
>>>
>>> I looked at assembly codes.  The new one is better.
>>> I will check it in.
>>
>> OK, but remove the equivalent code in num_sign_bit_copies1 then, otherwise
>> someone in a couple of years from now will adapt it to nonzero_bits1 and we
>> will be back to square one.
>>
>
> I am testing this patch on x32 branch.  I will compare glibc binaries before and
> after.
>

There are no code differences in glibc.  I will check it in.

Thanks.

H.J.
> --
> H.J.
> ---
> diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
> index e5c045d..0be6504 100644
> --- a/gcc/rtlanal.c
> +++ b/gcc/rtlanal.c
> @@ -4605,21 +4605,6 @@ num_sign_bit_copies1 (const_rtx x, enum
> machine_mode mode, const_rtx known_x,
>                                         known_x, known_mode, known_ret);
>       result = MAX (1, MIN (num0, num1) - 1);
>
> -#ifdef POINTERS_EXTEND_UNSIGNED
> -      /* If pointers extend signed and this is an addition or subtraction
> -        to a pointer in Pmode, all the bits above ptr_mode are known to be
> -        sign bit copies.  */
> -      /* As we do not know which address space the pointer is refering to,
> -        we can do this only if the target does not support different pointer
> -        or address modes depending on the address space.  */
> -      if (target_default_pointer_address_modes_p ()
> -         && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
> -         && (code == PLUS || code == MINUS)
> -         && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
> -       result = MAX ((int) (GET_MODE_BITSIZE (Pmode)
> -                            - GET_MODE_BITSIZE (ptr_mode) + 1),
> -                     result);
> -#endif
>       return result;
>
>     case MULT:
>
diff mbox

Patch

diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c
index e5c045d..0be6504 100644
--- a/gcc/rtlanal.c
+++ b/gcc/rtlanal.c
@@ -4605,21 +4605,6 @@  num_sign_bit_copies1 (const_rtx x, enum
machine_mode mode, const_rtx known_x,
 					 known_x, known_mode, known_ret);
       result = MAX (1, MIN (num0, num1) - 1);

-#ifdef POINTERS_EXTEND_UNSIGNED
-      /* If pointers extend signed and this is an addition or subtraction
-	 to a pointer in Pmode, all the bits above ptr_mode are known to be
-	 sign bit copies.  */
-      /* As we do not know which address space the pointer is refering to,
-	 we can do this only if the target does not support different pointer
-	 or address modes depending on the address space.  */
-      if (target_default_pointer_address_modes_p ()
-	  && ! POINTERS_EXTEND_UNSIGNED && GET_MODE (x) == Pmode
-	  && (code == PLUS || code == MINUS)
-	  && REG_P (XEXP (x, 0)) && REG_POINTER (XEXP (x, 0)))
-	result = MAX ((int) (GET_MODE_BITSIZE (Pmode)
-			     - GET_MODE_BITSIZE (ptr_mode) + 1),
-		      result);
-#endif
       return result;