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:
@@ -1739,12 +1739,21 @@
|
||||
(cmp (OperandSize.Size32) rcond (zero_reg))
|
||||
(Cond.Ne) ty rn rm)))
|
||||
|
||||
(rule -3 (lower (has_type ty (select rcond rn rm)))
|
||||
(rule -3 (lower (has_type ty (select rcond @ (value_type (fits_in_64 _)) rn rm)))
|
||||
(let ((rcond Reg (put_in_reg_zext64 rcond)))
|
||||
(lower_select
|
||||
(cmp (OperandSize.Size64) rcond (zero_reg))
|
||||
(Cond.Ne) ty rn rm)))
|
||||
|
||||
(rule -4 (lower (has_type ty (select rcond @ (value_type $I128) rn rm)))
|
||||
(let ((c ValueRegs (put_in_regs rcond))
|
||||
(c_lo Reg (value_regs_get c 0))
|
||||
(c_hi Reg (value_regs_get c 1))
|
||||
(rt Reg (orr $I64 c_lo c_hi)))
|
||||
(lower_select
|
||||
(cmp (OperandSize.Size64) rt (zero_reg))
|
||||
(Cond.Ne) ty rn rm)))
|
||||
|
||||
;;;; Rules for `select_spectre_guard` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type ty
|
||||
@@ -1761,12 +1770,21 @@
|
||||
(_ InstOutput (side_effect (csdb))))
|
||||
dst))
|
||||
|
||||
(rule -1 (lower (has_type ty (select_spectre_guard rcond rn rm)))
|
||||
(rule -1 (lower (has_type ty (select_spectre_guard rcond @ (value_type (fits_in_64 _)) rn rm)))
|
||||
(let ((rcond Reg (put_in_reg_zext64 rcond)))
|
||||
(lower_select
|
||||
(cmp (OperandSize.Size64) rcond (zero_reg))
|
||||
(Cond.Ne) ty rn rm)))
|
||||
|
||||
(rule -2 (lower (has_type ty (select_spectre_guard rcond @ (value_type $I128) rn rm)))
|
||||
(let ((c ValueRegs (put_in_regs rcond))
|
||||
(c_lo Reg (value_regs_get c 0))
|
||||
(c_hi Reg (value_regs_get c 1))
|
||||
(rt Reg (orr $I64 c_lo c_hi)))
|
||||
(lower_select
|
||||
(cmp (OperandSize.Size64) rt (zero_reg))
|
||||
(Cond.Ne) ty rn rm)))
|
||||
|
||||
;;;; Rules for `vconst` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (ty_vec128 _) (vconst (u128_from_constant x))))
|
||||
|
||||
Reference in New Issue
Block a user