riscv64: Add masking for small types when lowering select (#5504)
When lowering `select+icmp` we have an optimization that allows us to avoid materializing the icmp result. We were accidentally not masking the high bits for i8 and i16 in this case. Issue #5498 reported this as an illegal instruction but what was happening there was that the invalid select caused a division by zero.
This commit is contained in:
18
cranelift/filetests/filetests/runtests/issue-5498.clif
Normal file
18
cranelift/filetests/filetests/runtests/issue-5498.clif
Normal file
@@ -0,0 +1,18 @@
|
||||
test interpret
|
||||
test run
|
||||
target aarch64
|
||||
target s390x
|
||||
target x86_64
|
||||
target riscv64
|
||||
|
||||
function %a(i16, i8) -> i16 {
|
||||
block0(v0: i16, v1: i8):
|
||||
v2 = iconst.i16 0
|
||||
v3 = iconst.i16 1
|
||||
|
||||
v4 = ishl v0, v1
|
||||
v5 = icmp eq v4, v2
|
||||
v6 = select v5, v3, v4
|
||||
return v6
|
||||
}
|
||||
; run: %a(514, -1) == 1
|
||||
Reference in New Issue
Block a user