https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120356
Bug ID: 120356
Summary: [16 Regression] RISC-V: Miscompile at -O[23]
Product: gcc
Version: 16.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:
unsigned char a = 5;
signed char b[8][18][18][18];
long long c[18];
long long aj;
char e = 9;
short g = 60;
unsigned q = 143;
char s = 119;
int u = 2;
void d(char e, short g, unsigned q, char s, int u) {
for (short i = 0; i < g; i += 65413)
for (signed j = 0; j < 5; j++)
for (short k = 0; k < 18; k++)
if (e) {
for (unsigned l = 0; l < 18; l++) {
b[4][j][k][l] = 0;
if (g ? u : e)
a *= 0 > e ? 0 : q;
}
for (char l = 0; l < 8; l++)
for (int m = 0; m < 18; m++)
c[m] = 0;
}
}
int main() {
d(e, g, q, s, u);
aj ^= a;
for (int am = 0; am < 8; ++am)
aj ^= c[am];
__builtin_printf("%llu\n", aj);
}
Commands:
# -O3
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64gcv_zvl256b -flto -O3 -mrvv-vector-bits=zvl red.c -o
> user-config.out -fsigned-char -fno-strict-aliasing -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
> timeout --verbose -k 0.1 4
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out
> 1
5
# -O2
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64gcv_zvl256b -flto -O2 -mrvv-vector-bits=zvl red.c -o
> user-config.out -fsigned-char -fno-strict-aliasing -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
> timeout --verbose -k 0.1 4
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out
> 1
5
# -O1
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64gcv_zvl256b -flto -O1 -mrvv-vector-bits=zvl red.c -o
> user-config.out -fsigned-char -fno-strict-aliasing -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
> timeout --verbose -k 0.1 4
> /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out
> 1
69
bisected to r15-6881-g7b815107f40 as the first bad commit
Found via fuzzer.