On Thu, Jul 28, 2011 at 4:25 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Thu, Jul 28, 2011 at 3:46 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >> On Thu, Jul 28, 2011 at 3:40 PM, Uros Bizjak <ubiz...@gmail.com> wrote: >>> On Fri, Jul 29, 2011 at 12:28 AM, H.J. Lu <hjl.to...@gmail.com> wrote: >>> >>>>>>>>>>>> TP is 32bit in x32 For load_tp_x32, we load SImode value and >>>>>>>>>>>> zero-extend to DImode. For add_tp_x32, we are adding SImode >>>>>>>>>>>> value. We can't pretend TP is 64bit. load_tp_x32 and add_tp_x32 >>>>>>>>>>>> must take SImode TP. >>>>> >>>>>> Here is the revised patch. The difference is I changed *add_tp_x32 to >>>>>> SImode. >>>>>> For >>>>>> >>>>>> --- >>>>>> extern __thread int __libc_errno __attribute__ ((tls_model >>>>>> ("initial-exec"))); >>>>>> >>>>>> int * >>>>>> __errno_location (void) >>>>>> { >>>>>> return &__libc_errno; >>>>>> } >>>>>> --- >>>>>> >>>>>> compiled with -mx32 -O2 -fPIC DImode *add_tp_x32 generates: >>>>>> >>>>>> movq __libc_errno@gottpoff(%rip), %rax >>>>>> addl %fs:0, %eax >>>>>> mov %eax, %eax >>>>>> ret >>>>>> >>>>>> SImode *add_tp_x32 generates: >>>>>> >>>>>> movl %fs:0, %eax >>>>>> addl __libc_errno@gottpoff(%rip), %eax >>>>>> ret >>>>> >>>>> This happens because combine can't combine DImode load and SImode plus >>>>> RTXes. These RTXes have to be in Pmode, see the intention in >>>>> legitimize_tls_address, also for TARGET_GNU2_TLS. >>>>> >>>>> Can you please debug what goes wrong with tp_add_x32 in DImode? >>>>> >>>> >>>> We start with >>> >>> Uh, we didn't understand each other... can you please debug what goes >>> wrong with glibc runtime test? >>> >> >> I haven't be able to reproduce it. I may have a typo when I fixed the >> pattern. I will try again. >> > > I can't reproduce it any more. >
I know why. I also have (*load_tp_<mode>): Disabled for TARGET_X32. (*add_tp_<mode>): Likewise. since the SImode version is wrong for x32 due to (define_mode_attr tp_seg [(SI "gs") (DI "fs")]) x32 uses fs even if it is 32bit. -- H.J.