https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119115
Bug ID: 119115
Summary: [15 regression] RISC-V: miscompile at -O3 with zvl256b
-fsigned-char -fwrapv since r15-1579-g792f97b44ff
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: ewlu at rivosinc dot com
Target Milestone: ---
testcase:
short a[4][14][14];
void b(short d, short e, _Bool f, short g, int h, int i, char j, int k,
int l, short m[][14], char n[], unsigned short o[][14][14], short p[]) {
for (unsigned q = 0; q < (char)i; q++)
for (unsigned char r = 0; r < (char)(-1748723647U * m[q][q]) - 20; r++)
a[q][q][r] = p[q] || o[q][q][r];
}
long long seed;
short d;
short e;
_Bool f;
short g;
int h;
int i = 15963650;
char j;
int k;
int l;
short m[4][14];
char n[4];
unsigned short o[4][14][14];
short p[4];
int main() {
for (int q = 0; q < 4; ++q) {
p[q] = 4084;
for (int r = 0; r < 4; ++r) {
m[q][r] = 24482;
for (int u = 0; u < 4; ++u)
a[q][r][u] = 81;
}
}
b(d, e, f, g, h, i, j, k, l, m, n, o, p);
for (int q = 0; q < 4; ++q)
for (int r = 0; r < 4; ++r)
for (int u = 0; u < 14; ++u)
seed ^= a[q][r][u] + (seed >> 2);
__builtin_printf("%llu\n", seed);
}
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64gcv_zvl256b -O3 ../../test-llvm/red.c -o user-config.out
> -fsigned-char -fwrapv
>
> QEMU_CPU=rv64,vlen=256,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64
> user-config.out 1
1
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64gcv_zvl256b -O2 ../../test-llvm/red.c -o user-config.out
> -fsigned-char -fwrapv
>
> QEMU_CPU=rv64,vlen=256,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64
> user-config.out 1
0
x86 outputs 0.
Bisected to r15-1579-g792f97b44ff as the first bad commit.
Tried removing the extra arguments to b and the failure doesn't appear so not
sure if there is a simpler testcase.
found via fuzzer