On Thu, Jul 28, 2011 at 10:15 PM, 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? Uros.