https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121742
Bug ID: 121742
Summary: [15] RISC-V rv64gcv: miscompile at -O1/O2
Product: gcc
Version: 15.1.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>
typedef uint8_t a __attribute__((vector_size(4)));
int b, c;
uint64_t d() {
a e = {5, 9, 1, 5};
int *f = &b;
uint32_t g = 0;
int i = 0;
for (; i < 2; i++)
for (c = 0; c <= 2; c++) {
*f ^= e[3] + 9;
e = __builtin_shufflevector(
~__builtin_shufflevector((a){}, e, 1, 4, 3, 4), e, 0, 1, 1, 7);
}
return g;
}
int main() {
int j = d();
printf("%d\n", b);
}
Commands:
> riscv64-unknown-elf-gcc -O0 -march=rv64gcv reduced.c && qemu-riscv64 ./a.out
> 0
> riscv64-unknown-elf-gcc -O1 -march=rv64gcv reduced.c && qemu-riscv64 ./a.out
> 7
> riscv64-unknown-elf-gcc -O2 -march=rv64gcv reduced.c && qemu-riscv64 ./a.out
> 7
> riscv64-unknown-elf-gcc -O3 -march=rv64gcv reduced.c && qemu-riscv64 ./a.out
> 0