Remove the Cranelift vselect instruction (#5918)
* Remove the Cranelift `vselect` instruction This instruction is documented as selecting lanes based on the "truthy" value of the condition lane, but the current status of the implementation of this instruction is: * x64 - uses the high bit for `f32x4` and `f64x2` and otherwise uses the high bit of each byte doing a byte-wise lane select rather than whatever the controlling type is. * AArch64 - this is the same as `bitselect` which is a bit-wise selection rather than a lane-wise selection. * s390x - this is the same as AArch64, a bit-wise selection rather than lane-wise. * interpreter - the interpreter implements the documented semantics of selecting based on "truthy" values. Coupled with the status of the implementation is the fact that this instruction is not used by WebAssembly SIMD today either. The only use of this instruction in Cranelift is the nan-canonicalization pass. By moving nan-canonicalization to `bitselect`, since that has the desired semantics, there's no longer any need for `vselect`. Given this situation this commit subsqeuently removes `vselect` and all usage of it throughout Cranelift. Closes #5917 * Review comments * Bring back vselect opts as bitselect opts * Clean up vselect usage in the interpreter * Move bitcast in nan canonicalization * Add a comment about float optimization
This commit is contained in:
@@ -1659,11 +1659,6 @@
|
||||
(rule 1 (lower (has_type (ty_vec128 ty) (bitselect c x y)))
|
||||
(bsl ty c x y))
|
||||
|
||||
;;;; Rules for `vselect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type (ty_vec128 ty) (vselect c x y)))
|
||||
(bsl ty c x y))
|
||||
|
||||
;;;; Rules for `ireduce` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; T -> I{64,32,16,8}: We can simply pass through the value: values
|
||||
|
||||
@@ -1170,13 +1170,6 @@
|
||||
(vec_select ty y z x))
|
||||
|
||||
|
||||
;;;; Rules for `vselect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Vector select.
|
||||
(rule (lower (has_type (ty_vec128 ty) (vselect x y z)))
|
||||
(vec_select ty y z x))
|
||||
|
||||
|
||||
;;;; Rules for `bmask` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type ty (bmask x)))
|
||||
|
||||
@@ -1193,7 +1193,7 @@
|
||||
(sse_or ty b a)))
|
||||
|
||||
;; If every byte of the condition is guaranteed to be all ones or all zeroes,
|
||||
;; we can use x86_blend like vselect does.
|
||||
;; we can use x64_blend.
|
||||
(rule 1 (lower (has_type ty @ (multi_lane _bits _lanes)
|
||||
(bitselect condition
|
||||
if_true
|
||||
@@ -1226,15 +1226,6 @@
|
||||
(x86_blendv condition if_true if_false)))
|
||||
(x64_blendvpd if_false if_true condition))
|
||||
|
||||
;;;; Rules for `vselect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type ty @ (multi_lane _bits _lanes)
|
||||
(vselect condition if_true if_false)))
|
||||
(x64_blend ty
|
||||
condition
|
||||
if_true
|
||||
if_false))
|
||||
|
||||
;;;; Rules for `insertlane` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (insertlane vec @ (value_type ty) val (u8_from_uimm8 idx)))
|
||||
|
||||
Reference in New Issue
Block a user