Skip to content

Commit b8dc3ca

Browse files
committed
fix: missing checks in ty_int_ref_scalar_64, and we use it in place of fits_in_32 + ty_int
1 parent 1b2a4f8 commit b8dc3ca

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

cranelift/codegen/src/isa/aarch64/lower.isle

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,55 +51,55 @@
5151
;; `i64` and smaller
5252

5353
;; Base case, simply adding things in registers.
54-
(rule iadd_base_case -1 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y)))
54+
(rule iadd_base_case -1 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y)))
5555
(add ty x y))
5656

5757
;; Special cases for when one operand is an immediate that fits in 12 bits.
58-
(rule iadd_imm12_right 4 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (imm12_from_value y))))
58+
(rule iadd_imm12_right 4 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (imm12_from_value y))))
5959
(add_imm ty x y))
6060

61-
(rule iadd_imm12_left 5 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (imm12_from_value x) y)))
61+
(rule iadd_imm12_left 5 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (imm12_from_value x) y)))
6262
(add_imm ty y x))
6363

6464
;; Same as the previous special cases, except we can switch the addition to a
6565
;; subtraction if the negated immediate fits in 12 bits.
66-
(rule iadd_imm12_neg_right 2 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y)))
66+
(rule iadd_imm12_neg_right 2 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y)))
6767
(if-let imm12_neg (imm12_from_negated_value y))
6868
(sub_imm ty x imm12_neg))
6969

70-
(rule iadd_imm12_neg_left 3 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x y)))
70+
(rule iadd_imm12_neg_left 3 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x y)))
7171
(if-let imm12_neg (imm12_from_negated_value x))
7272
(sub_imm ty y imm12_neg))
7373

7474
;; Special cases for when we're adding an extended register where the extending
7575
;; operation can get folded into the add itself.
76-
(rule iadd_extend_right 0 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (extended_value_from_value y))))
76+
(rule iadd_extend_right 0 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (extended_value_from_value y))))
7777
(add_extend ty x y))
7878

79-
(rule iadd_extend_left 1 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (extended_value_from_value x) y)))
79+
(rule iadd_extend_left 1 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (extended_value_from_value x) y)))
8080
(add_extend ty y x))
8181

8282
;; Special cases for when we're adding the shift of a different
8383
;; register by a constant amount and the shift can get folded into the add.
84-
(rule iadd_ishl_right 7 (lower (has_type (fits_in_64 (ty_int ty))
84+
(rule iadd_ishl_right 7 (lower (has_type (ty_int_ref_scalar_64 ty)
8585
(iadd x (ishl y (iconst k)))))
8686
(if-let amt (lshl_from_imm64 ty k))
8787
(add_shift ty x y amt))
8888

89-
(rule iadd_ishl_left 6 (lower (has_type (fits_in_64 (ty_int ty))
89+
(rule iadd_ishl_left 6 (lower (has_type (ty_int_ref_scalar_64 ty)
9090
(iadd (ishl x (iconst k)) y)))
9191
(if-let amt (lshl_from_imm64 ty k))
9292
(add_shift ty y x amt))
9393

9494
;; Fold an `iadd` and `imul` combination into a `madd` instruction.
95-
(rule iadd_imul_right 7 (lower (has_type (fits_in_64 (ty_int ty)) (iadd x (imul y z))))
95+
(rule iadd_imul_right 7 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd x (imul y z))))
9696
(madd ty y z x))
9797

98-
(rule iadd_imul_left 6 (lower (has_type (fits_in_64 (ty_int ty)) (iadd (imul x y) z)))
98+
(rule iadd_imul_left 6 (lower (has_type (ty_int_ref_scalar_64 ty) (iadd (imul x y) z)))
9999
(madd ty x y z))
100100

101101
;; Fold an `isub` and `imul` combination into a `msub` instruction.
102-
(rule isub_imul (lower (has_type (fits_in_64 (ty_int ty)) (isub x (imul y z))))
102+
(rule isub_imul (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (imul y z))))
103103
(msub ty y z x))
104104

105105
;; vectors
@@ -720,27 +720,27 @@
720720
;; `i64` and smaller
721721

722722
;; Base case, simply subtracting things in registers.
723-
(rule isub_base_case -4 (lower (has_type (fits_in_64 (ty_int ty)) (isub x y)))
723+
(rule isub_base_case -4 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x y)))
724724
(sub ty x y))
725725

726726
;; Special case for when one operand is an immediate that fits in 12 bits.
727-
(rule isub_imm12 0 (lower (has_type (fits_in_64 (ty_int ty)) (isub x (imm12_from_value y))))
727+
(rule isub_imm12 0 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (imm12_from_value y))))
728728
(sub_imm ty x y))
729729

730730
;; Same as the previous special case, except we can switch the subtraction to an
731731
;; addition if the negated immediate fits in 12 bits.
732-
(rule isub_imm12_neg 2 (lower (has_type (fits_in_64 (ty_int ty)) (isub x y)))
732+
(rule isub_imm12_neg 2 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x y)))
733733
(if-let imm12_neg (imm12_from_negated_value y))
734734
(add_imm ty x imm12_neg))
735735

736736
;; Special cases for when we're subtracting an extended register where the
737737
;; extending operation can get folded into the sub itself.
738-
(rule isub_extend 1 (lower (has_type (fits_in_64 (ty_int ty)) (isub x (extended_value_from_value y))))
738+
(rule isub_extend 1 (lower (has_type (ty_int_ref_scalar_64 ty) (isub x (extended_value_from_value y))))
739739
(sub_extend ty x y))
740740

741741
;; Finally a special case for when we're subtracting the shift of a different
742742
;; register by a constant amount and the shift can get folded into the sub.
743-
(rule isub_ishl -3 (lower (has_type (fits_in_64 (ty_int ty))
743+
(rule isub_ishl -3 (lower (has_type (ty_int_ref_scalar_64 ty)
744744
(isub x (ishl y (iconst k)))))
745745
(if-let amt (lshl_from_imm64 ty k))
746746
(sub_shift ty x y amt))
@@ -790,7 +790,7 @@
790790
;;;; Rules for `imul` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
791791

792792
;; `i64` and smaller.
793-
(rule imul_base_case -3 (lower (has_type (fits_in_64 (ty_int ty)) (imul x y)))
793+
(rule imul_base_case -3 (lower (has_type (ty_int_ref_scalar_64 ty) (imul x y)))
794794
(madd ty x y (zero_reg)))
795795

796796
;; `i128`.

cranelift/codegen/src/isle_prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ macro_rules! isle_common_prelude_methods {
280280

281281
#[inline]
282282
fn ty_int_ref_scalar_64(&mut self, ty: Type) -> Option<Type> {
283-
if ty.bits() <= 64 && !ty.is_float() && !ty.is_vector() {
283+
if ty.bits() <= 64 && !ty.is_float() && !ty.is_vector() && !ty.is_dynamic_vector() {
284284
Some(ty)
285285
} else {
286286
None

0 commit comments

Comments
 (0)