On Thu, 15 Jun 2006 11:32:52 -0400, Daniel Jacobowitz <dan@xxxxxxxxxx> wrote: > > I also found a "rdhwr" in gcc's mips.md file ("tls_get_tp_<mode>"). > > Is this the origin? MD is a very foreign language for me... > > Yes. Compile something like this with -O2 but without -fpic: > > __thread int x; > int foo() { return x; } > > It should use the IE model, which will generate a rdhwr. Thanks. So this must be a gcc issue, not glibc issue. extern __thread int x; int foo(int arg) { if (arg) return x; return 0; } If I compiled this program with -O2 I got: foo: .frame $sp,0,$31 # vars= 0, regs= 0/0, args= 0, gp= 0 .mask 0x00000000,0 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro lw $2,%gottprel(x)($28) .set push .set mips32r2 rdhwr $3,$29 .set pop addu $2,$2,$3 beq $4,$0,$L4 move $3,$0 lw $3,0($2) $L4: j $31 move $2,$3 It looks too bad for arg == 0 case. I should ask on gcc list. --- Atsushi Nemoto