Cranelift: ISLE: aarch64: fix imm12_from_negated_value for i32, i16 (#6078)

* Fix the semantics of imm12_from_negated_value, swapping to a partial term + rule

* wrapping_neg
This commit is contained in:
Alexa VanHattum
2023-03-21 15:16:25 -04:00
committed by GitHub
parent 59d46c2fec
commit 13be5618a7
6 changed files with 140 additions and 28 deletions

View File

@@ -56,11 +56,13 @@
;; Same as the previous special cases, except we can switch the addition to a
;; subtraction if the negated immediate fits in 12 bits.
(rule 2 (lower (has_type (fits_in_64 ty) (iadd x (imm12_from_negated_value y))))
(sub_imm ty x y))
(rule 2 (lower (has_type (fits_in_64 ty) (iadd x y)))
(if-let imm12_neg (imm12_from_negated_value y))
(sub_imm ty x imm12_neg))
(rule 3 (lower (has_type (fits_in_64 ty) (iadd (imm12_from_negated_value x) y)))
(sub_imm ty y x))
(rule 3 (lower (has_type (fits_in_64 ty) (iadd x y)))
(if-let imm12_neg (imm12_from_negated_value x))
(sub_imm ty y imm12_neg))
;; Special cases for when we're adding an extended register where the extending
;; operation can get folded into the add itself.
@@ -650,8 +652,9 @@
;; Same as the previous special case, except we can switch the subtraction to an
;; addition if the negated immediate fits in 12 bits.
(rule 2 (lower (has_type (fits_in_64 ty) (isub x (imm12_from_negated_value y))))
(add_imm ty x y))
(rule 2 (lower (has_type (fits_in_64 ty) (isub x y)))
(if-let imm12_neg (imm12_from_negated_value y))
(add_imm ty x imm12_neg))
;; Special cases for when we're subtracting an extended register where the
;; extending operation can get folded into the sub itself.