https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115018
Bug ID: 115018
Summary: Incorrect data read/written at -O3 on Arm with 256-bit
SVE SIMD width specified
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: erik at kth dot se
Target Milestone: ---
Created attachment 58154
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58154&action=edit
Source code to reproduce the bug (only includes 3x std headers)
Hi GCC,
When testing Gromacs on Amazon's Graviton3 Arm nodes with SVE support using
Ubuntu 24.04 with gcc-13.2.0, I have been tracking down a strange failed unit
test that occurs in non-SVE code, but only when I manually specify 256-bit SVE
length (instead of auto).
This code had a ton of dependencies on Google test and other files, but I think
I have been able to isolated it to a small file that only includes vector and
array - see attachment.
The code in question creates a std::vector with 10 elements, where each element
is a std::array with 3 floats. Initially they are all set to zero, and then I
add (0,10,0) to all elements.
With this combination of high optimization and 256-bit SVE, only some of the
elements will be updated, while the other ones are still (0,0,0):
g++ -O3 -march=armv8.2-a+sve -msve-vector-bits=256 bug.cpp -Wall -Wextra
-fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations
If I remove either then -O3, or -msve-vector-bits=256, the results are fine.
The bug also disappears if I don't have this slightly-complex multi-level
inheritance, or if I use plain C arrays instead of std containers, or remove
any of the other seemingly stupid constructs in the attached example - but at
least I saved you from having to debug all of Google test :-)