Cranelift: Implement 'iabs' for scalar types on x86_64 (#5527)
* Implement 'iabs' for scalar types on x86_64 * Small fix
This commit is contained in:
@@ -1129,6 +1129,20 @@
|
||||
(neg Xmm (x64_psubq (imm $I64X2 0) rx)))
|
||||
(x64_blendvpd neg rx neg)))
|
||||
|
||||
;; `i64` and smaller.
|
||||
|
||||
(rule -1 (lower (has_type (fits_in_64 ty) (iabs x)))
|
||||
(let ((src Gpr x)
|
||||
(neg ProducesFlags (x64_neg_paired ty src))
|
||||
;; Manually extract the result from the neg, then ignore
|
||||
;; it below, since we need to pass it into the cmove
|
||||
;; before we pass the cmove to with_flags_reg.
|
||||
(neg_result Gpr (produces_flags_get_reg neg))
|
||||
;; When the neg instruction sets the sign flag,
|
||||
;; takes the original (non-negative) value.
|
||||
(cmove ConsumesFlags (cmove ty (CC.S) src neg_result)))
|
||||
(with_flags_reg (produces_flags_ignore neg) cmove)))
|
||||
|
||||
;;;; Rules for `fabs` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (has_type $F32 (fabs x)))
|
||||
|
||||
@@ -362,6 +362,7 @@
|
||||
;; Get the produced register out of a ProducesFlags.
|
||||
(decl produces_flags_get_reg (ProducesFlags) Reg)
|
||||
(rule (produces_flags_get_reg (ProducesFlags.ProducesFlagsReturnsReg _ reg)) reg)
|
||||
(rule (produces_flags_get_reg (ProducesFlags.ProducesFlagsReturnsResultWithConsumer _ reg)) reg)
|
||||
|
||||
;; Modify a ProducesFlags to use it only for its side-effect, ignoring
|
||||
;; its result.
|
||||
|
||||
Reference in New Issue
Block a user