Issue 243341
Summary [RISC-V][P-ext] Miscompile of `<2 x i32>` select on RV32
Labels backend:RISC-V, miscompilation
Assignees
Reporter zeyi2
    ### Reproducer

https://godbolt.org/z/refPnTsqd

```llvm
; llc -mtriple=riscv32 -mattr=+experimental-p -O2
define i64 @s6(i64 %a.coerce, i64 %c.coerce) {
  %a = bitcast i64 %a.coerce to <2 x i32>
  %c = bitcast i64 %c.coerce to <2 x i32>
  %cmp = icmp ugt <2 x i32> %a, %c
  %or = select <2 x i1> %cmp, <2 x i32> <i32 0, i32 7>, <2 x i32> <i32 16, i32 7>
 %r = bitcast <2 x i32> %or to i64
  ret i64 %r
}
```

Expected: lane 0 = `a0 >u c0 ? 0 : 16`, lane 1 = 7. For a = {5, 0}, c = {3, 9} the result should be {0, 7}.

Actual:

```asm
s6:
        pmsltu.dw       a0, a2, a0
 addi    a0, a0, -1
        andi    a0, a0, 16
        li      a1, 7
 ret
```

Lane 0 is always 16 (it returns {16, 7} for the inputs above). The input has no UB or poison.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to