Fixes #5199.
Fixes #5200.
Fixes #5452.
Fixes #5453.
On riscv64, there is apparently an autoconversion from `ValueRegs` to
`Reg` that takes just the low register [0], and removing this conversion
causes 48 errors. As a result of this, `select` with an `i128` condition
was silently miscompiling, testing only the low 64 bits. We should
remove this autoconversion to ensure we aren't missing any other silent
truncations, but for now this PR just adds the explicit `I128` logic for
`select` / `select_spectre_guard`.
[0]
d9fdbfd50e/cranelift/codegen/src/isa/riscv64/inst.isle (L1762)
38 lines
1.5 KiB
Plaintext
38 lines
1.5 KiB
Plaintext
test run
|
|
set enable_llvm_abi_extensions=true
|
|
target aarch64
|
|
target s390x
|
|
target x86_64
|
|
target riscv64
|
|
|
|
function %i128_select(i8, i128, i128) -> i128 {
|
|
block0(v0: i8, v1: i128, v2: i128):
|
|
v3 = select.i128 v0, v1, v2
|
|
return v3
|
|
}
|
|
; run: %i128_select(1, 0, 1) == 0
|
|
; run: %i128_select(0, 0, 1) == 1
|
|
; run: %i128_select(1, 0x00000000_00000000_DECAFFFF_C0FFEEEE, 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF) == 0x00000000_00000000_DECAFFFF_C0FFEEEE
|
|
; run: %i128_select(0, 0x00000000_00000000_DECAFFFF_C0FFEEEE, 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF) == 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF
|
|
|
|
;; Test for issue: https://github.com/bytecodealliance/wasmtime/issues/3963.
|
|
function %i128_fcmp_eq_select(f32, i128, i128) -> i128 {
|
|
block0(v0: f32, v1: i128, v2: i128):
|
|
v3 = fcmp eq v0, v0
|
|
v4 = select.i128 v3, v1, v2
|
|
return v4
|
|
}
|
|
; run: %i128_fcmp_eq_select(0x42.42, 1, 0) == 1
|
|
; run: %i128_fcmp_eq_select(NaN, 1, 0) == 0
|
|
|
|
function %i128_cond_select(i128, i128, i128) -> i128 {
|
|
block0(v0: i128, v1: i128, v2: i128):
|
|
v3 = select.i128 v0, v1, v2
|
|
return v3
|
|
}
|
|
; run: %i128_cond_select(1, 0, 1) == 0
|
|
; run: %i128_cond_select(0, 0, 1) == 1
|
|
; run: %i128_cond_select(1, 0x00000000_00000000_DECAFFFF_C0FFEEEE, 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF) == 0x00000000_00000000_DECAFFFF_C0FFEEEE
|
|
; run: %i128_cond_select(0, 0x00000000_00000000_DECAFFFF_C0FFEEEE, 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF) == 0xFFFFFFFF_FFFFFFFF_C0FFEEEE_DECAFFFF
|
|
; run: %i128_cond_select(0x1_00000000_00000000, 2, 3) == 2
|