https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80881

--- Comment #103 from LIU Hao <lh_mouse at 126 dot com> ---
New test results on master:

```
UCRT64 ~/Desktop
$ cat test.c
extern __thread int i[8];

int foo (void)
{
  return i[2] + i[4];
}

UCRT64 ~/Desktop
$ x86_64-w64-mingw32-gcc --version
x86_64-w64-mingw32-gcc.exe (GCC with MCF thread model, built by LH_Mouse)
15.0.1 20250205 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


UCRT64 ~/Desktop
$ x86_64-w64-mingw32-gcc test.c -O2 -c && objdump -dr test.o

test.o:     file format pe-x86-64


Disassembly of section .text:

0000000000000000 <foo>:
   0:   8b 05 00 00 00 00       mov    eax,DWORD PTR [rip+0x0]        # 6
<foo+0x6>
                        2: IMAGE_REL_AMD64_REL32        _tls_index
   6:   65 48 8b 14 25 58 00    mov    rdx,QWORD PTR gs:0x58
   d:   00 00
   f:   48 8b 14 c2             mov    rdx,QWORD PTR [rdx+rax*8]
  13:   8b 82 10 00 00 00       mov    eax,DWORD PTR [rdx+0x10]
                        15: IMAGE_REL_AMD64_SECREL      i
  19:   03 82 08 00 00 00       add    eax,DWORD PTR [rdx+0x8]
                        1b: IMAGE_REL_AMD64_SECREL      i
  1f:   c3                      ret

MINGW32 ~/Desktop
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc.exe (GCC with MCF thread model, built by LH_Mouse) 15.0.1
20250205 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


MINGW32 ~/Desktop
$ i686-w64-mingw32-gcc test.c -O2 -c && objdump -dr test.o

test.o:     file format pe-i386


Disassembly of section .text:

00000000 <_foo>:
   0:   a1 00 00 00 00          mov    eax,ds:0x0
                        1: dir32        __tls_index
   5:   64 8b 15 2c 00 00 00    mov    edx,DWORD PTR fs:0x2c
   c:   8b 14 82                mov    edx,DWORD PTR [edx+eax*4]
   f:   8b 82 10 00 00 00       mov    eax,DWORD PTR [edx+0x10]
                        11: secrel32    _i
  15:   03 82 08 00 00 00       add    eax,DWORD PTR [edx+0x8]
                        17: secrel32    _i
  1b:   c3                      ret
  1c:   90                      nop
  1d:   90                      nop
  1e:   90                      nop
  1f:   90                      nop

```

Reply via email to