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

"Reshma.Roy at amd 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

--- Comment #2 from Reshma Roy <Reshma.Roy at amd dot com> ---
(In reply to H.J. Lu from comment #1)
> (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

Output: 

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++,fortran
--disable-bootstrap --disable-multilib --prefix=~/GCC/install : (reconfigured)
../gcc/configure --disable-bootstrap --disable-multilib
--prefix=/home/amd/reshma/GCC/install --enable-languages=c,c++,fortran,lto
--no-create --no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260722 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-mtune=native' '-O3' '-mavx512f' '-mavx512dq' '-mfma'
'-fstack-protector-strong' '-std=c11' '-fPIC' '-S' '-o' 'testcase.s'
'-march=x86-64'
 ~/GCC/install/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1 -fpreprocessed
repro-standalone-min-bad-fix-new.i --param l1-cache-size=48 --param
l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=znver5 -quiet -dumpbase
testcase.i -dumpbase-ext .i -mavx512f -mavx512dq -mfma -march=x86-64 -O3
-std=c11 -version -fstack-protector-strong -fPIC -o testcase.s
GNU C11 (GCC) version 17.0.0 20260722 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 13.3.0, GMP version 6.3.0, MPFR version
4.2.2, MPC version 1.3.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 635c8853492582f21a9f9857f7e4e59d
COMPILER_PATH=~/GCC/install/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/:~/GCC/install/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/:~/GCC/install/libexec/gcc/x86_64-pc-linux-gnu/:~/GCC/install/lib/gcc/x86_64-pc-linux-gnu/17.0.0/:~/GCC/install/lib/gcc/x86_64-pc-linux-gnu/
LIBRARY_PATH=~/GCC/install/lib/../lib64/:/home/amd/reshma/GCC/install/lib64/../lib64/:~/GCC/install/lib/gcc/x86_64-pc-linux-gnu/17.0.0/:~/GCC/install/lib/gcc/x86_64-pc-linux-gnu/17.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:~/GCC/install/lib/:/home/amd/reshma/GCC/install/lib64/:./:~/GCC/install/lib/gcc/x86_64-pc-linux-gnu/17.0.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=native' '-O3' '-mavx512f' '-mavx512dq' '-mfma'
'-fstack-protector-strong' '-std=c11' '-fPIC' '-S' '-o' 'testcase.s'
'-march=x86-64' '-dumpdir' 'testcase.'
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.