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:
Chris Fallin
2022-12-16 14:18:22 -08:00
committed by GitHub
parent d9fdbfd50e
commit 22439f7b39
7 changed files with 64 additions and 22 deletions

View File

@@ -704,9 +704,6 @@ const OPCODE_SIGNATURES: &'static [(
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Bitselect, &[I128, I128, I128], &[I128], insert_opcode),
// Select
// TODO: Some ops disabled:
// x64: https://github.com/bytecodealliance/wasmtime/issues/5199
// AArch64: https://github.com/bytecodealliance/wasmtime/issues/5200
(Opcode::Select, &[I8, I8, I8], &[I8], insert_opcode),
(Opcode::Select, &[I8, I16, I16], &[I16], insert_opcode),
(Opcode::Select, &[I8, I32, I32], &[I32], insert_opcode),
@@ -727,20 +724,12 @@ const OPCODE_SIGNATURES: &'static [(
(Opcode::Select, &[I64, I32, I32], &[I32], insert_opcode),
(Opcode::Select, &[I64, I64, I64], &[I64], insert_opcode),
(Opcode::Select, &[I64, I128, I128], &[I128], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Select, &[I128, I8, I8], &[I8], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Select, &[I128, I16, I16], &[I16], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Select, &[I128, I32, I32], &[I32], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Select, &[I128, I64, I64], &[I64], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::Select, &[I128, I128, I128], &[I128], insert_opcode),
// SelectSpectreGuard
// TODO: Some ops disabled:
// x64: https://github.com/bytecodealliance/wasmtime/issues/5452
// AArch64: https://github.com/bytecodealliance/wasmtime/issues/5453
(Opcode::SelectSpectreGuard, &[I8, I8, I8], &[I8], insert_opcode),
(Opcode::SelectSpectreGuard, &[I8, I16, I16], &[I16], insert_opcode),
(Opcode::SelectSpectreGuard, &[I8, I32, I32], &[I32], insert_opcode),
@@ -761,15 +750,10 @@ const OPCODE_SIGNATURES: &'static [(
(Opcode::SelectSpectreGuard, &[I64, I32, I32], &[I32], insert_opcode),
(Opcode::SelectSpectreGuard, &[I64, I64, I64], &[I64], insert_opcode),
(Opcode::SelectSpectreGuard, &[I64, I128, I128], &[I128], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::SelectSpectreGuard, &[I128, I8, I8], &[I8], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::SelectSpectreGuard, &[I128, I16, I16], &[I16], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::SelectSpectreGuard, &[I128, I32, I32], &[I32], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::SelectSpectreGuard, &[I128, I64, I64], &[I64], insert_opcode),
#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
(Opcode::SelectSpectreGuard, &[I128, I128, I128], &[I128], insert_opcode),
// Fadd
(Opcode::Fadd, &[F32, F32], &[F32], insert_opcode),