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

            Bug ID: 120089
           Summary: GCC miscompiles VK-GL-CTS on aarch64 with -O3
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cwabbott0 at gmail dot com
  Target Milestone: ---

Created attachment 61286
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61286&action=edit
reproducer

Since I upgraded to Fedora 42 with GCC 15.1.1, when using -O3 (which is the
default CMake configuration in a release build) GCC miscompiles a function in
https://github.com/KhronosGroup/VK-GL-CTS which results in some Vulkan tests
failing. I've built GCC trunk as of today and it also fails.

I've attached a self-contained reproducer, here's a godbolt link too:
https://godbolt.org/z/arjr31dd1 note that running programs on godbolt compiled
with GCC 15 on aarch64 seems to be broken (even hello world segfaults) so you
can't reproduce the bug on godbolt. However it does show that x86-64 is
unaffected so the bug may be target-specific. The correct output, as seen with
-O2, is:

0 0 0 0 0 0 0 0 0 0 64 191 0 0 96 191 0 0 96 191 0 0 32 191 0 0 32 191 0 0 32
191 0 0 128 190 0 0 96 191 0 0 192 190 0 0 32 191 0 0 0 190 0 0 32 191 0 0 128
62 0 0 96 191 0 0 0 62 0 0 32 191 0 0 192 62 0 0 32 191 0 0 64 63 0 0 96 191 0
0 32 63 0 0 32 191 0 0 96 63 0 0 32 191 0 0 64 191 0 0 192 190 0 0 96 191 0 0 0
190 0 0 32 191 0 0 0 190 0 0 128 190 0 0 192 190 0 0 192 190 0 0 0 190 0 0 0
190 0 0 0 190 0 0 128 62 0 0 192 190 0 0 0 62 0 0 0 190 0 0 192 62 0 0 0 190 0
0 64 63 0 0 192 190 0 0 32 63 0 0 0 190 0 0 96 63 0 0 0 190 0 0 64 191 0 0 0 62
0 0 96 191 0 0 192 62 0 0 32 191 0 0 192 62 0 0 128 190 0 0 0 62 0 0 192 190 0
0 192 62 0 0 0 190 0 0 192 62 0 0 128 62 0 0 0 62 0 0 0 62 0 0 192 62 0 0 192
62 0 0 192 62 0 0 64 63 0 0 0 62 0 0 32 63 0 0 192 62 0 0 96 63 0 0 192 62 0 0
64 191 0 0 32 63 0 0 96 191 0 0 96 63 0 0 32 191 0 0 96 63 0 0 128 190 0 0 32
63 0 0 192 190 0 0 96 63 0 0 0 190 0 0 96 63 0 0 128 62 0 0 32 63 0 0 0 62 0 0
96 63 0 0 192 62 0 0 96 63 0 0 64 63 0 0 32 63 0 0 32 63 0 0 96 63 0 0 96 63 0
0 96 63

but when miscompiled it outputs:

0 0 0 0 0 0 0 0 0 0 64 191 0 0 96 191 0 0 96 191 0 0 32 191 0 0 32 191 0 0 32
191 0 0 128 190 0 0 96 191 0 0 192 190 0 0 32 191 0 0 0 190 0 0 32 191 0 0 128
62 0 0 96 191 0 0 0 62 0 0 32 191 0 0 192 62 0 0 32 191 0 0 64 63 0 0 96 191 0
0 32 63 0 0 32 191 0 0 192 62 0 0 96 63 0 0 64 63 0 0 32 63 0 0 32 63 0 0 96 63
0 0 96 63 0 0 96 63 0 0 128 190 0 0 192 190 0 0 192 190 0 0 0 190 0 0 0 190 0 0
0 190 0 0 128 62 0 0 192 190 0 0 0 62 0 0 0 190 0 0 192 62 0 0 0 190 0 0 64 63
0 0 192 190 0 0 32 63 0 0 0 190 0 0 96 63 0 0 0 190 0 0 64 191 0 0 0 62 0 0 96
191 0 0 192 62 0 0 32 191 0 0 192 62 0 0 128 190 0 0 0 62 0 0 192 190 0 0 192
62 0 0 0 190 0 0 192 62 0 0 128 62 0 0 0 62 0 0 0 62 0 0 192 62 0 0 192 62 0 0
192 62 0 0 64 63 0 0 0 62 0 0 32 63 0 0 192 62 0 0 96 63 0 0 192 62 0 0 64 191
0 0 32 63 0 0 96 191 0 0 96 63 0 0 32 191 0 0 96 63 0 0 128 190 0 0 32 63 0 0
192 190 0 0 96 63 0 0 0 190 0 0 96 63 0 0 128 62 0 0 32 63 0 0 0 62 0 0 96 63 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

with the last few bytes being replaced with 0's.

The reproducer is based on
https://github.com/KhronosGroup/VK-GL-CTS/blob/b2b40c06daf915417234ebbe64b2ec7580a2c1be/external/vulkancts/modules/vulkan/pipeline/vktPipelineInputAttributeOffsetTests.cpp#L178
with inputs taken from one of the failing tests.

Reply via email to