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

            Bug ID: 123786
           Summary: [16 Regression] 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: ---

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_u32(x) ((uint32_t)vqadd_u64((uint64x1_t){x},
(uint64x1_t){})[0])
uint32_t g_11[7][1];
uint8_t g_21[8][9];
int32_t g_36[3];
int8_t g_82, g_179, func_66_BS_COND_13, g_101;
void func_6(uint8_t, int8_t, uint8_t)
{
BS_LABEL_3:
    int16_t l_65 = g_21[3][7];
    if (func_66_BS_COND_13) goto BS_LABEL_6;
    for (; g_101; g_101 = 5)
    {
    BS_LABEL_6:
    }
    for (; g_82 >= 0; g_82 -= 1)
    {
        switch (BARRIER_u32(0))
        {
            case 4: goto BS_LABEL_3;
            case 9: goto BS_LABEL_3;
        }
        int16_t si1 = (l_65 &= 1) || (g_179 &= 0) != 6;
        g_36[0] = g_36[2] == 0 ?: si1 / g_36[2];
    }
}
void func_3(uint16_t) { func_6(g_11[2][0], 0, g_11[2][0]); }
void func_1() { func_6(g_11[2][0], 0, g_11[2][0]); }
int main()
{
    func_1();
    printf("checksum = %08X\n", g_36[0]);
}

Commands:
> aarch64-unknown-linux-musl-gcc -O3 -march=armv9-a -static a.c
> qemu-aarch64 a.out
> checksum = 00000000

> aarch64-unknown-linux-musl-gcc -O2 -march=armv9-a -static a.c
> qemu-aarch64 a.out
> checksum = 00000001

gcc version 16.0.1 20260120 (experimental)

Reply via email to