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

            Bug ID: 123544
           Summary: [16 Regression] AArch64: Wrong code at -O1
           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 20260108 (experimental)
qemu-aarch64 version 10.1.2

Testcase:
#include <stdint.h>
#include <stdio.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num)))
uint64_t BS_CHECKSUM;
int8_t backsmith_pure_0() {}
uint32_t backsmith_pure_4(BS_VEC(uint8_t, 4) BS_ARG_1, int16_t BS_ARG_2,
                          int64_t BS_ARG_5)
{
    _BitInt(15) BS_VAR_0 = 828;
    BS_VAR_0 &= (unsigned)BS_ARG_5 < 5 ? 0 : (unsigned)BS_ARG_1[1];
    if (BS_ARG_2) return BS_VAR_0;
    for (uint16_t BS_INC_0; BS_INC_0;)
        ;
}
int32_t func_8(uint8_t p_9)
{
    uint64_t BS_VAR_0[] = {};
    uint64_t LOCAL_CHECKSUM =
        backsmith_pure_4((BS_VEC(uint8_t, 4)){ 1, 1, 1 }, 1, -1);
    if (p_9)
    {
        BS_CHECKSUM += LOCAL_CHECKSUM;
        return 0;
    }
    BS_VAR_0[backsmith_pure_4((BS_VEC(uint8_t, 4)){}, 0, backsmith_pure_0())];
}
int main()
{
    func_8(1);
    printf("BackSmith Checksum = 0x%016llx\n", BS_CHECKSUM);
}

Command:
> aarch64-unknown-linux-musl-gcc -O1 -static a.c
> qemu-aarch64 a.out
Output:
> BackSmith Checksum = 0x0000000000000100

Command:
> aarch64-unknown-linux-musl-gcc -O0 -static a.c
> qemu-aarch64 a.out
Output:
> BackSmith Checksum = 0x0000000000000000

Reply via email to