support select_spectre_guard and select on i128 conditions on all platforms. (#5460)
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)
This commit is contained in:
@@ -24,3 +24,14 @@ block0(v0: f32, v1: i128, v2: i128):
|
||||
}
|
||||
; 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;; the interpreter does not support `select_spectre_guard`.
|
||||
test interpret
|
||||
test run
|
||||
set enable_llvm_abi_extensions=true
|
||||
target aarch64
|
||||
@@ -314,3 +314,13 @@ block0(v0: i8, v1: i128, v2: i128):
|
||||
; run: %select_spectre_guard_i128_sle(127, 32, -1) == -1
|
||||
; run: %select_spectre_guard_i128_sle(127, 32, 19000000000000000000) == 19000000000000000000
|
||||
; run: %select_spectre_guard_i128_sle(42, 32, 19000000000000000000) == 32
|
||||
|
||||
function %select_spectre_guard_i128_cond(i128, i128, i128) -> i128 {
|
||||
block0(v0: i128, v1: i128, v2: i128):
|
||||
v3 = select_spectre_guard.i128 v0, v1, v2
|
||||
return v3
|
||||
}
|
||||
; run: %select_spectre_guard_i128_cond(1, 2, 3) == 2
|
||||
; run: %select_spectre_guard_i128_cond(0, 2, 3) == 3
|
||||
; run: %select_spectre_guard_i128_cond(18446744073709551616, 2, 3) == 2
|
||||
; run: %select_spectre_guard_i128_cond(18446744073709551616, 18446744073709551616, 3) == 18446744073709551616
|
||||
|
||||
Reference in New Issue
Block a user