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:
Afonso Bordado
2023-01-03 19:59:14 +00:00
committed by GitHub
parent f911855612
commit 7e94704264
3 changed files with 30 additions and 6 deletions

View 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