Cranelift: aarch64: lower umin.i64 and friends (#5495)
* Cranelift: aarch64: lower umin.i64 and friends * fuzzgen: Enable integer-min/max for aarch64
This commit is contained in:
@@ -887,6 +887,36 @@
|
||||
|
||||
;;; Rules for integer min/max: umin, smin, umax, smax ;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; `i64` and smaller.
|
||||
|
||||
;; cmp $x, $y
|
||||
;; csel .., $x, $y, $cc
|
||||
(decl cmp_and_choose (Type Cond bool Value Value) ValueRegs)
|
||||
(rule (cmp_and_choose (fits_in_64 ty) cc _ x y)
|
||||
(let ((x Reg (put_in_reg x))
|
||||
(y Reg (put_in_reg y)))
|
||||
(with_flags_reg (cmp (operand_size ty) x y)
|
||||
(csel cc x y))))
|
||||
|
||||
;; `i16` and `i8` min/max require sign extension as
|
||||
;; the comparison operates on (at least) 32 bits.
|
||||
(rule 1 (cmp_and_choose (fits_in_16 ty) cc signed x y)
|
||||
(let ((x Reg (extend (put_in_reg x) signed (ty_bits ty) 32))
|
||||
(y Reg (extend (put_in_reg y) signed (ty_bits ty) 32)))
|
||||
(with_flags_reg (cmp (operand_size ty) x y)
|
||||
(csel cc x y))))
|
||||
|
||||
(rule 2 (lower (has_type (and (fits_in_64 ty) (ty_int _)) (umin x y)))
|
||||
(cmp_and_choose ty (Cond.Lo) $false x y))
|
||||
(rule 2 (lower (has_type (and (fits_in_64 ty) (ty_int _)) (smin x y)))
|
||||
(cmp_and_choose ty (Cond.Lt) $true x y))
|
||||
(rule 2 (lower (has_type (and (fits_in_64 ty) (ty_int _)) (umax x y)))
|
||||
(cmp_and_choose ty (Cond.Hi) $false x y))
|
||||
(rule 2 (lower (has_type (and (fits_in_64 ty) (ty_int _)) (smax x y)))
|
||||
(cmp_and_choose ty (Cond.Gt) $true x y))
|
||||
|
||||
;; Vector types.
|
||||
|
||||
(rule (lower (has_type ty @ (not_i64x2) (smin x y)))
|
||||
(vec_rrr (VecALUOp.Smin) x y (vector_size ty)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user