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

            Bug ID: 123285
           Summary: [Trunk] AArch64: Miscompile 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: ---

gcc version 16.0.0 20251220 (experimental)
Testcase:
#include <stdint.h>
#include <stdio.h>
#include <arm_neon.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
#define BARRIER_u8() vqadd_u64((uint64x1_t){}, (uint64x1_t){})[0]
uint64_t BS_CHECKSUM;
uint16_t g_16;
int32_t g_35;
int64_t func_25(uint16_t *, uint16_t *);
uint16_t *func_28(int16_t, uint32_t);
int32_t *func_41(const int32_t *);
uint64_t func_1()
{
    int8_t l_14 = 0;
    uint16_t *l_31 = &g_16;
    func_25(func_28(l_14, l_14), l_31);
    return 0;
}
int64_t func_25(uint16_t *, uint16_t *)
{
    int32_t l_2088 = 0;
    func_41(&g_35);
    return l_2088;
}
uint16_t *func_28(int16_t, uint32_t) { return &g_16; }
int32_t *func_41(const int32_t *)
{
    BS_VEC(uint8_t, 32) BS_VAR_1[44] = {};
    uint64_t LOCAL_CHECKSUM = 0;
    int32_t l_58 = 10;
    for (g_35 = 4; g_35; g_35 -= 1)
    {
        __asm("" ::: "v30");
        BS_VAR_1[BS_VAR_1[6][9] < 4 ? BARRIER_u8() : 0] -=
                (BS_VEC(uint8_t, 32)){ l_58, l_58, l_58, l_58, l_58, l_58,
l_58,
                                       l_58, l_58, l_58, l_58, l_58, l_58,
l_58,
                                       l_58, l_58, l_58 };
    }
    for (uint32_t BS_TEMP_398 = 0; BS_TEMP_398 < 44; BS_TEMP_398++)
        for (uint32_t BS_TEMP_399 = 0; BS_TEMP_399 < 2; BS_TEMP_399++)
            LOCAL_CHECKSUM ^=
                BS_VAR_1[BS_TEMP_398][BS_TEMP_399] + LOCAL_CHECKSUM >> 2;
    BS_CHECKSUM += LOCAL_CHECKSUM;
    return 0;
}
int main()
{
    func_1();
    printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}

Commands:
> aarch64-unknown-linux-musl-gcc -O2 -static a.c
> qemu-aarch64 ./a.out
BackSmith Checksum = 0x0000000000000072
> aarch64-unknown-linux-musl-gcc -O3 -static a.c
> qemu-aarch64 ./a.out
BackSmith Checksum = 0x0000000000000075

Reply via email to