On Mon, Mar 12, 2012 at 3:35 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
> On Mon, Mar 12, 2012 at 12:39 PM, Uros Bizjak <ubiz...@gmail.com> wrote:
>> On Sun, Mar 11, 2012 at 10:24 PM, H.J. Lu <hjl.to...@gmail.com> wrote:
>>
>>> Here is the patch which is equivalent to clearing MASK_TLS_DIRECT_SEG_REFS
>>> when Pmode != word_mode.  We need to keep
>>>
>>>          else if (Pmode == SImode)
>>>            {
>>>              /* Always generate
>>>                        movl %fs:0, %reg32
>>>                        addl xgottpoff(%rip), %reg32
>>>                 to support linker IE->LE optimization and avoid
>>>                 fs:(%reg32) as memory operand.  */
>>>              dest = gen_reg_rtx (Pmode);
>>>              emit_insn (gen_tls_initial_exec_x32 (dest, x));
>>>              return dest;
>>>            }
>>>
>>> to support linker IE->LE optimization.  TARGET_TLS_DIRECT_SEG_REFS only 
>>> affects
>>> TLS LE access and fs:(%reg) is only generated by combine.
>>>
>>> So the main impact of disabling TARGET_TLS_DIRECT_SEG_REFS is to disable
>>> fs:immediate memory operand for TLS LE access, which doesn't have any 
>>> problems
>>> to begin with.
>>>
>>> I would prefer to keep TARGET_TLS_DIRECT_SEG_REFS and disable only
>>> fs:(%reg), which is generated by combine.
>>
>> Please try attached patch.  It introduces TARGET_TLS_INDIRECT_SEG_REFS
>> to block only indirect seg references.
>>
>> Uros.
>
> I am testing it.
>

There is no regression.

BTW, this x32 TLS IE optimization:

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

is still useful.  For

[hjl@gnu-6 tls]$ cat ie2.i
extern __thread long long int x;

extern long long int y;

void
ie2 (void)
{
  x = y;
}
[hjl@gnu-6 tls]$

my patch turns

ie2:
.LFB0:
        .cfi_startproc
        movq    y(%rip), %rdx   # 6     *movdi_internal_rex64/2 [length = 7]
        movl    %fs:0, %eax     # 5     tls_initial_exec_x32    [length = 16]
        addl    x@gottpoff(%rip), %eax
        movq    %rdx, (%eax)    # 7     *movdi_internal_rex64/4 [length = 3]
        ret     # 14    simple_return_internal  [length = 1]
        .cfi_endproc

into

ie2:
.LFB0:
        .cfi_startproc
        movq    y(%rip), %rax   # 6     *movdi_internal_rex64/2 [length = 7]
        movq    x@gottpoff(%rip), %rdx  # 7     *tls_initial_exec_x32_store     
[length = 16]
        movq    %rax, %fs:(%rdx)
        ret     # 14    simple_return_internal  [length = 1]
        .cfi_endproc



-- 
H.J.

Reply via email to