https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121957
Bug ID: 121957
Summary: [16] AArch64: Miscompile at -O2/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 20250907 (experimental)
Testcase:
#include <stdint.h>
#include <stdio.h>
#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))
typedef int64_t int64;
uint64_t g;
uint64_t func_1() {
BS_VEC(uint64_t, 16) BS_VAR_4 = {};
asm goto("" : : : : BS_LABEL_1);
BS_LABEL_2:
asm goto("" : : : : BS_LABEL_1);
BS_LABEL_0:
asm goto("" : : : : BS_LABEL_2);
BS_VAR_4 = 0 == __builtin_shufflevector(
__builtin_shufflevector(
(BS_VEC(int64_t, 32)){80383229547, 80383229547,
80383229547,
80383229547, 80383229547, 80383229547,
80383229547, 80383229547, 80383229547,
80383229547},
(BS_VEC(int64_t, 32)){}, 28, 3, 5, 8, 9, 8, 3, 7, 4, 3, 3,
2,
9, 7, 5, 0),
(BS_VEC(int64_t, 16)){}, 2, 6, 3, 2, 4, 9, 4, 9, 2, 3, 0, 3,
7,
7, 1, 0);;
asm goto("" : : : : BS_LABEL_0);
BS_LABEL_1:
asm goto("" : : : : BS_LABEL_0);
g = BS_VAR_4[3];
return 0;
}
int main() {
func_1();
printf("0x%016llx\n", g);
}
Commands:
> aarch64-unknown-linux-gnu-gcc -O0/O1 reduced.c && qemu-aarch64 a.out
> 0x0000000000000000
> aarch64-unknown-linux-gnu-gcc -O2/O3 reduced.c && qemu-aarch64 a.out
> 0x0000000000496d88