Accept [u8; N] bitmasks in simd_select_bitmask

Fixes rust-lang/rustc_codegen_cranelift#1446
This commit is contained in:
bjorn3 2024-01-26 14:19:11 +00:00
parent dc7ed1680c
commit 604c8a7cf8
3 changed files with 31 additions and 25 deletions

View File

@ -133,8 +133,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
"rust-lang",
"portable-simd",
"4825b2a64d765317066948867e8714674419359b",
"9e67d07c00f5fb0b",
"97007cc2e70df8c97326ce896a79e2f0ce4dd98b",
"e54a16035cedf205",
"portable-simd",
);

View File

@ -1,22 +0,0 @@
From a101a43b795431ce617e7782afb451f4853afc00 Mon Sep 17 00:00:00 2001
From: bjorn3 <17426603+bjorn3@users.noreply.github.com>
Date: Thu, 7 Dec 2023 14:51:35 +0000
Subject: [PATCH] Enable the exposed_provenance feature
---
crates/core_simd/tests/pointers.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/crates/core_simd/tests/pointers.rs b/crates/core_simd/tests/pointers.rs
index 0ae8f83..06620d6 100644
--- a/crates/core_simd/tests/pointers.rs
+++ b/crates/core_simd/tests/pointers.rs
@@ -1,4 +1,4 @@
-#![feature(portable_simd, strict_provenance)]
+#![feature(exposed_provenance, portable_simd, strict_provenance)]
use core_simd::simd::{Simd, SimdConstPtr, SimdMutPtr};
--
2.34.1

View File

@ -822,7 +822,35 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
let (lane_count, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx);
let lane_layout = fx.layout_of(lane_ty);
let m = m.load_scalar(fx);
let expected_int_bits = lane_count.max(8);
let expected_bytes = expected_int_bits / 8 + ((expected_int_bits % 8 > 0) as u64);
let m = match m.layout().ty.kind() {
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => m.load_scalar(fx),
ty::Array(elem, len)
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
== Some(expected_bytes) =>
{
m.force_stack(fx).0.load(
fx,
Type::int(expected_int_bits as u16).unwrap(),
MemFlags::trusted(),
)
}
_ => {
fx.tcx.dcx().span_fatal(
span,
format!(
"invalid monomorphization of `simd_select_bitmask` intrinsic: \
cannot accept `{}` as mask, expected `u{}` or `[u8; {}]`",
ret.layout().ty,
expected_int_bits,
expected_bytes
),
);
}
};
for lane in 0..lane_count {
let m_lane = fx.bcx.ins().ushr_imm(m, u64::from(lane) as i64);