| Issue |
242771
|
| Summary |
[RISCV] RV32 experimental P miscompiles i64 right shifts as widening left shifts
|
| Labels |
backend:RISC-V,
miscompilation
|
| Assignees |
zeyi2
|
| Reporter |
zeyi2
|
On RV32 with `+experimental-p`, an `i64` logical right shift of a zero-extended `i32` is incorrectly lowered to `wsll`, a widening left shift.
Reproducer: https://godbolt.org/z/oebYchch5
```llvm
define i64 @srl(i32 %x, i64 %s) {
%z = zext i32 %x to i64
%r = lshr i64 %z, %s
ret i64 %r
}
```
Compile with `llc -mtriple=riscv32 -mattr=+experimental-p -O2`:
```asm
srl:
wsll a0, a0, a1
ret
```
For `%x = 1020` and `%s = 2`, the expected result is 255, but the generated instruction computes 4080 according to the P-extension specification.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs