| Issue |
244988
|
| Summary |
[RISCV] -Os miscompilation with -march=rv64gcv upon a `<32 x i7>` multiplication
|
| Labels |
generated by fuzzer
|
| Assignees |
|
| Reporter |
hazohelet
|
Live Reproducer: [https://godbolt.org/z/67c7Y4eE7](<https://godbolt.org/z/67c7Y4eE7>)
Compiling the following C code for `riscv64` with `clang -Os -march=rv64gcv` and running it prints the wrong result.
```c
#include <stdio.h>
_BitInt(7) g = 1;
int n = 1;
int main(void) {
_BitInt(7) l = 1;
for (int i = 0; i < n; i++)
l *= g;
printf("%d\n", (int)l);
}
```
clang command:
```sh
clang --target=riscv64-linux-gnu -march=rv64gcv -Os -static repro.c && qemu-riscv64 -cpu max ./a.out
```
Output (wrong):
```text
0
```
Expected (what -O0 prints, and what x86-64 prints):
```text
1
```
Notes:
* Only `-Os` is wrong. `-O0` to `-O3` and `-Oz` are correct
* Correct with `-fno-vectorize`, `-march=rv64gc`
* Also wrong with clang 23.1.2; 22.1.8 is correct
clang version:
```text
clang version 24.0.0git (https://github.com/llvm/llvm-project aab5b2033768c13c0753538df9f8940ada9d8b45)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs