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

            Bug ID: 123625
           Summary: [14/15/16 Regression] AArch64: wrong code at -O3
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xxs_chy at outlook dot com
  Target Milestone: ---

Testcase:
#include <stdint.h>
#include <stdio.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
uint64_t BS_CHECKSUM, g_284;
struct U0
{
    int16_t f0;
    int64_t f2
} g_205;
int16_t g_8, func_2_BS_COND_1;
uint8_t g_9[2][1];
volatile struct U0 g_121[];
int64_t *g_565 = &g_284;
int main()
{
    BS_VEC(int64_t, 16) BS_VAR_3 = { 1, 8096386231136, 9039249955151 };
    uint64_t LOCAL_CHECKSUM = 0;
    switch (func_2_BS_COND_1)
    {
        case 2: goto BS_LABEL_0;
        case 4: goto BS_LABEL_0;
    }
    for (g_8 = 0; g_8 <= 0; g_8 += 1)
        for (g_205.f2 = 0; g_205.f2 <= 1; g_205.f2 += 1)
        {
            if (g_9[g_205.f2][0])
            BS_LABEL_0:
                for (;;)
                    ;
            for (uint32_t BS_TEMP_371 = 0; BS_TEMP_371 < 16; BS_TEMP_371++)
                LOCAL_CHECKSUM ^= BS_VAR_3[BS_TEMP_371] + 9
                        + (LOCAL_CHECKSUM << 6) + LOCAL_CHECKSUM
                    >> (*g_565 |= g_121[0].f0);
            BS_VAR_3 = (BS_VEC(int64_t, 16)){};
        }
    BS_CHECKSUM = LOCAL_CHECKSUM;
    printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}

Commands:
> aarch64-unknown-linux-musl-gcc -O1 -static a.c && qemu-aarch64 a.out
> aarch64-unknown-linux-musl-gcc -O3 -static a.c && qemu-aarch64 a.out
Output:
> BackSmith Checksum = 0x7237237237237237
> BackSmith Checksum = 0x302b03b33f237237

gcc version 16.0.1 20260114 (experimental)

Reply via email to