https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94542
Bug ID: 94542 Summary: test gcc/testsuite/gcc.dg/tls/pr24428-2.c generates incorrect code on ppc64le with -mpcrel -mcpu=future -O2 Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: acsawdey at gcc dot gnu.org Target Milestone: --- The test case is: __thread double thrtest[81]; int main () { double *p, *e; e = &thrtest[81]; for (p = &thrtest[0]; p < e; ++p) *p = 1.0; return 0; } Generated code for p and e is paddi 9,13,thrtest@tprel pla 8,thrtest+648@pcrel The second should also be using a @tprel relocation. Because it didn't, the loop runs off the end of allocated memory and segfaults. This test runs correctly when compiled with -O0. Compile command: /home2/sawdey/work/gcc/mamboCI/build-mambo/gcc/xgcc -B/home2/sawdey/work/gcc/mamboCI/build-mambo/gcc/ /home2/sawdey/work/gcc/mamboCI/pike-trunk/gcc/testsuite/gcc.dg/tls/pr24428-2.c -O2 -mpcrel -mcpu=future -S -o pr24428-2.exe.s