Skip to content

Commit 0bfae9c

Browse files
committed
fix for new type guard
1 parent 64983e8 commit 0bfae9c

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

cranelift/codegen/src/isle_prelude.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,15 @@ macro_rules! isle_common_prelude_methods {
533533
ty.is_int().then(|| ty)
534534
}
535535

536+
#[inline]
537+
fn ty_int_vec128(&mut self, ty: Type) -> Option<Type> {
538+
if ty.is_int() || (ty.is_vector() && ty.bits() == 128 && ty.lane_type().is_int()) {
539+
Some(ty)
540+
} else {
541+
None
542+
}
543+
}
544+
536545
#[inline]
537546
fn ty_scalar(&mut self, ty: Type) -> Option<Type> {
538547
if ty.lane_count() == 1 { Some(ty) } else { None }

cranelift/codegen/src/prelude.isle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@
505505
(decl ty_vec128 (Type) Type)
506506
(extern extractor ty_vec128 ty_vec128)
507507

508+
(decl ty_int_vec128 (Type) Type)
509+
(extern extractor ty_int_vec128 ty_int_vec128)
510+
508511
;; An extractor that only matches dynamic vector types with a 64-bit
509512
;; base type.
510513
(decl ty_dyn_vec64 (Type) Type)

cranelift/codegen/src/prelude_opt.isle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
(if-let true (i64_eq c c_reextended))
143143
(iconst ty (imm64 c_masked)))
144144
(rule 1 (iconst_s $I128 c) (sextend $I128 (iconst_s $I64 c)))
145+
(rule 2 (iconst_s (ty_vec128 ty) c) (splat ty (iconst_s (lane_type ty) c)))
145146

146147
;; Construct an `iconst` from a `u64` or Extract a `u64` from an `iconst`
147148
;; by treating the constant as unsigned.
@@ -157,6 +158,7 @@
157158
(if-let true (u64_lt_eq c (ty_umax ty)))
158159
(iconst ty (imm64 c)))
159160
(rule 1 (iconst_u $I128 c) (uextend $I128 (iconst_u $I64 c)))
161+
(rule 2 (iconst_u (ty_vec128 ty) c) (splat ty (iconst_u (lane_type ty) c)))
160162

161163
;; These take `Value`, rather than going through `inst_data_value_tupled`,
162164
;; because most of the time they want to return the original `Value`, and it

0 commit comments

Comments
 (0)