[PATCH] Fix ix86_split_long_move collision handling with TLS (PR target/66470)
Uros Bizjak
ubizjak@gmail.com
Tue Jun 9 14:06:00 GMT 2015
On Tue, Jun 9, 2015 at 3:39 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Jun 09, 2015 at 03:21:55PM +0200, Uros Bizjak wrote:
>> I'm afraid that simple scan loop won't work correctly on x32. There
>> are some issues with UNSPEC_TP for this target, so we have to generate
>> zero_extend of SImode UNSPEC, e.g.:
>>
>> (plus:DI (zero_extend:DI (unspec:SI [...] UNSPEC_TP) (reg:DI ...))
>>
>> as can be seen in get_thread_pointer to construct the address. It
>> looks that your loop won't find the UNSPEC_TP tag in the above case.
>
> You're right, for -m32 it would need to start with
> rtx *x = &addr;
> + while (GET_CODE (*x) == ZERO_EXTEND
> + || GET_CODE (*x) == AND
> + || GET_CODE (*x) == SUBREG)
> + x = &XEXP (*x, 0);
> to get at the PLUS. Now, with either the original patch with the above
> ammendment, or with the iterators, the question is what to do
> with the UNSPEC_TP for -m32. Is it ok to just use addr32 on the
> lea and use normal Pmode (== DImode) addressing for the memory reads
> (if I read the code well, that is what it does right now for the non-TLS
> ones:
> if (GET_MODE (base) != Pmode)
> base = gen_rtx_REG (Pmode, REGNO (base));
> )? Then we'd need to change tls_base mode to Pmode.
(I assume you referred to -mx32 above. Please also note that -mx32
uses Pmode == SImode by default).
Yes, please emit zero-extended address load to a DImode register, and
use this register with UNSPEC_TP to form final DImode address. The LEA
that will be generated from address load will use DImode inputs due to
%H operand modifier and will output to (implicitly zero-extended)
SImode register.
FYI, you just hit two special cases here:
- addresses that mention %fs and %gs are always in DImode
- LEA input operands are also always in DImode, but compiler already
takes care of it.
Uros.
More information about the Gcc-patches
mailing list