[Bug target/126382] [16/17 regression] Incorrect compiler generated code resulting in seg fault - hoisted tls() in x86_cse caused register clobbering

"hjl.tools at gmail dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126382

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-07-24

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Reshma Roy from comment #0)
> Created attachment 65120 [details]
> The preprocessed input file to be used for the command mentioned in the
> description
> 
> GCC version: gcc (GCC) 17.0.0 20260722 (experimental)
> 
> GCC trunk generates incorrect code for AVX stack-realigned functions. This
> causes a null pointer to dereference in libFLAME's legacy test suite
> during Hessenberg reduction (FLA_Obj_datatype_check.c:18).
> 
> Bisection points to 5cf1b9a03ec5b617af8c50c1e9c0d223083fd7f2 ("x86-64:
> Remove redundant TLS calls").
> 
> -----------------------------------------------------------------------------
> --
> Reduced test case:
> 
> typedef struct { long n; long m_inner; long n_inner; int base; } FLA_Obj;
> __thread FLA_Obj FLA_ONE, W12;
> long FLA_Obj_length ();
> void FLA_Obj_width ();
> void f (FLA_Obj A)
> {
>   while (FLA_Obj_length (A))
>     FLA_Obj_width (FLA_ONE);
>   FLA_Obj_width (FLA_ONE, W12);
> }
> 
> Reproducer: gcc -mtune=native -O3 -mavx512f -mavx512dq -mfma
> -fstack-protector-strong -fpie -std=c11 -fPIC -S -o testcase.s testcase.i
> 

Please show the output of

$ gcc -v -mtune=native -O3 -mavx512f -mavx512dq -mfma -fstack-protector-strong
-fpie -std=c11 -fPIC -S -o testcase.s testcase.i
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.