diff mbox

PATCH: Properly generate X32 IE sequence

Message ID CAFULd4biwrSQOPbs0sChJ=0Sn_KvYKD5jQy+6QVpxe2NtVRexA@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak March 13, 2012, 10:37 a.m. UTC
On Tue, Mar 13, 2012 at 8:11 AM, Uros Bizjak <ubizjak@gmail.com> wrote:

>>>> Please try attached patch.  It introduces TARGET_TLS_INDIRECT_SEG_REFS
>>>> to block only indirect seg references.
>>
>> There is no regression.
>
> Thanks, committed to mainline SVN with following ChangeLog:
>
> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>
>        * config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
>        * config/i386/i386.c (ix86_decompose_address): Use
>        TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
>        (legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
>        thread pointer to a register.
>
> Tested on x86_64-pc-linux-gnu {,-m32}.
>
>> BTW, this x32 TLS IE optimization:
>
>  >    movq    %rax, %fs:(%rdx)
>
> This is just looking for troubles. If we said these addresses are
> invalid, then we shouldn't generate them.

OTOH,  we can improve rejection test a bit to reject only non-word
mode registers.

2012-03-13  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.c (ix86_decompose_address): Prevent %fs:(%reg)
	addresses only when %reg is not in word mode.

Tested on x86_64-pc-linux-gnu {,-m32}, committed.

Uros.

Comments

H.J. Lu March 13, 2012, 3:47 p.m. UTC | #1
On Tue, Mar 13, 2012 at 3:37 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Mar 13, 2012 at 8:11 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>>>>> Please try attached patch.  It introduces TARGET_TLS_INDIRECT_SEG_REFS
>>>>> to block only indirect seg references.
>>>
>>> There is no regression.
>>
>> Thanks, committed to mainline SVN with following ChangeLog:
>>
>> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>>
>>        * config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
>>        * config/i386/i386.c (ix86_decompose_address): Use
>>        TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
>>        (legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
>>        thread pointer to a register.
>>
>> Tested on x86_64-pc-linux-gnu {,-m32}.
>>
>>> BTW, this x32 TLS IE optimization:
>>
>>  >    movq    %rax, %fs:(%rdx)
>>
>> This is just looking for troubles. If we said these addresses are
>> invalid, then we shouldn't generate them.
>
> OTOH,  we can improve rejection test a bit to reject only non-word
> mode registers.
>
> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>
>        * config/i386/i386.c (ix86_decompose_address): Prevent %fs:(%reg)
>        addresses only when %reg is not in word mode.
>
> Tested on x86_64-pc-linux-gnu {,-m32}, committed.
>
> Uros.
>
> Index: i386.c
> ===================================================================
> --- i386.c      (revision 185278)
> +++ i386.c      (working copy)
> @@ -11563,8 +11563,10 @@
>        return 0;
>     }
>
> -  if (seg != SEG_DEFAULT && (base || index)
> -      && !TARGET_TLS_INDIRECT_SEG_REFS)
> +/* Address override works only on the (%reg) part of %fs:(%reg).  */
> +  if (seg != SEG_DEFAULT
> +      && ((base && GET_MODE (base) != word_mode)
> +         || (index && GET_MODE (index) != word_mode)))
>     return 0;
>
>   /* Extract the integral value of scale.  */

This works.
H.J. Lu March 17, 2012, 5:52 p.m. UTC | #2
On Tue, Mar 13, 2012 at 3:37 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Mar 13, 2012 at 8:11 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>
>>>>> Please try attached patch.  It introduces TARGET_TLS_INDIRECT_SEG_REFS
>>>>> to block only indirect seg references.
>>>
>>> There is no regression.
>>
>> Thanks, committed to mainline SVN with following ChangeLog:
>>
>> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>>
>>        * config/i386/i386.h (TARGET_TLS_INDIRECT_SEG_REFS): New.
>>        * config/i386/i386.c (ix86_decompose_address): Use
>>        TARGET_TLS_INDIRECT_SEG_REFS to prevent %fs:(%reg) addresses.
>>        (legitimize_tls_address): Use TARGET_TLS_INDIRECT_SEG_REFS to load
>>        thread pointer to a register.
>>
>> Tested on x86_64-pc-linux-gnu {,-m32}.
>>
>>> BTW, this x32 TLS IE optimization:
>>
>>  >    movq    %rax, %fs:(%rdx)
>>
>> This is just looking for troubles. If we said these addresses are
>> invalid, then we shouldn't generate them.
>
> OTOH,  we can improve rejection test a bit to reject only non-word
> mode registers.
>
> 2012-03-13  Uros Bizjak  <ubizjak@gmail.com>
>
>        * config/i386/i386.c (ix86_decompose_address): Prevent %fs:(%reg)
>        addresses only when %reg is not in word mode.
>
> Tested on x86_64-pc-linux-gnu {,-m32}, committed.
>
> Uros.
>
> Index: i386.c
> ===================================================================
> --- i386.c      (revision 185278)
> +++ i386.c      (working copy)
> @@ -11563,8 +11563,10 @@
>        return 0;
>     }
>
> -  if (seg != SEG_DEFAULT && (base || index)
> -      && !TARGET_TLS_INDIRECT_SEG_REFS)
> +/* Address override works only on the (%reg) part of %fs:(%reg).  */
> +  if (seg != SEG_DEFAULT
> +      && ((base && GET_MODE (base) != word_mode)
> +         || (index && GET_MODE (index) != word_mode)))
>     return 0;
>
>   /* Extract the integral value of scale.  */

Is my x32 TLS IE optimization:

http://gcc.gnu.org/ml/gcc-patches/2012-03/msg00714.html

OK for trunk?

Thanks.
diff mbox

Patch

Index: i386.c
===================================================================
--- i386.c      (revision 185278)
+++ i386.c      (working copy)
@@ -11563,8 +11563,10 @@ 
        return 0;
     }

-  if (seg != SEG_DEFAULT && (base || index)
-      && !TARGET_TLS_INDIRECT_SEG_REFS)
+/* Address override works only on the (%reg) part of %fs:(%reg).  */
+  if (seg != SEG_DEFAULT
+      && ((base && GET_MODE (base) != word_mode)
+         || (index && GET_MODE (index) != word_mode)))
     return 0;

   /* Extract the integral value of scale.  */