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

--- Comment #118 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <[email protected]>:

https://gcc.gnu.org/g:680df0a476512393e6e9cbd0255d3863baacf826

commit r16-6023-g680df0a476512393e6e9cbd0255d3863baacf826
Author: Eric Botcazou <[email protected]>
Date:   Thu Dec 11 10:02:35 2025 +0100

    i386: Fix and rework Windows TLS support

    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.

    gcc/
            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.

    gcc/testsuite/
            * gcc.dg/tls/struct-2.c: New test.

Reply via email to