On Tue, Jun 9, 2015 at 2:57 PM, Jakub Jelinek <ja...@redhat.com> wrote:
> On Tue, Jun 09, 2015 at 02:32:07PM +0200, Uros Bizjak wrote:
>> > -         emit_insn (gen_rtx_SET (base, XEXP (part[1][0], 0)));
>> > +         addr = XEXP (part[1][0], 0);
>> > +         if (TARGET_TLS_DIRECT_SEG_REFS)
>> > +           {
>> > +             struct ix86_address parts;
>> > +             int ok = ix86_decompose_address (addr, &parts);
>> > +             gcc_assert (ok);
>> > +             if (parts.seg == DEFAULT_TLS_SEG_REG)
>> > +               {
>> > +                 /* It is not valid to use %gs: or %fs: in
>> > +                    lea though, so we need to remove it from the
>> > +                    address used for lea and add it to each individual
>> > +                    memory loads instead.  */
>> > +                 addr = copy_rtx (addr);
>> > +                 rtx *x = &addr;
>> > +                 while (GET_CODE (*x) == PLUS)
>>
>> Why not use RTX iterators here? IMO, it would be much more readable.
>
> Do you mean something like this?  It is larger and don't see readability
> advantages there at all (plus the 4.8/4.9 backports can't use that anyway).
> But if you prefer it, I can retest it.

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.

Uros.

Reply via email to