On Wed, Dec 10, 2025 at 3:45 PM Eric Botcazou <[email protected]> wrote:
>
> Hi,
>
> The compiler can emit invalid movabs instructions at -O0 for TLS accesses in
> 64-bit mode on Windows, for example with the attached testcase:
>
> eric@fomalhaut:~/build/gcc/x86_64-w64-mingw32> gcc/xgcc -Bgcc -c struct-2.c
> /tmp/ccOM8wdd.s: Assembler messages:
> /tmp/ccOM8wdd.s:34: Error: operand type mismatch for `movabs'
>
> This fixes the issue by leveraging the existing pic_32bit_operand predicate,
> and fixing an oversight present in it for a couple of decades.  The patch also
> reworks the support to make use of the get_thread_pointer machinery as for
> other platforms, of more comments and of shorter lines.
>
> Tested on i686-w64-mingw32 and x86_64-w64-mingw32, OK for the mainline?
>
>
> 2025-12-10  Eric Botcazou  <[email protected]>
>
>         PR target/80881
>         * config/i386/i386.h (DEFAULT_TLS_SEG_OFFSET): New define.
>         * config/mingw/mingw32.h (DEFAULT_TLS_SEG_OFFSET): Likewise.
>         * config/i386/i386.cc (ix86_tls_index): Fix long line.
>         (legitimize_tls_address): Use get_thread_pointer, add comments and
>         fix long lines.
>         * config/i386/i386.md (*load_tp_<mode>): Use DEFAULT_TLS_SEG_OFFSET
>         (*load_tp_x32_zext): Likewise.
>         (*add_tp_<mode>): Likewise.
>         (*add_tp_x32_zext): Likewise.
>         * config/i386/predicates.md (pic_32bit_operand): Fix oversight.
>         (symbolic_operand): Accept UNSPEC_SECREL32 with or without offset.
>
>
> 2025-12-10  Eric Botcazou  <[email protected]>
>
>         * gcc.dg/tls/struct-2.c: New test.

Generic x86 changes are OK, and pic_32bit_operand change should be
backported to other release branches.

Thanks,
Uros.

Reply via email to