Skip to content

Commit 604c8a7

Browse files
committed
Accept [u8; N] bitmasks in simd_select_bitmask
Fixes #1446
1 parent dc7ed16 commit 604c8a7

File tree

3 files changed

+31
-25
lines changed

3 files changed

+31
-25
lines changed

build_system/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ pub(crate) static REGEX: CargoProject = CargoProject::new(&REGEX_REPO.source_dir
133133
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
134134
"rust-lang",
135135
"portable-simd",
136-
"4825b2a64d765317066948867e8714674419359b",
137-
"9e67d07c00f5fb0b",
136+
"97007cc2e70df8c97326ce896a79e2f0ce4dd98b",
137+
"e54a16035cedf205",
138138
"portable-simd",
139139
);
140140

patches/0001-portable-simd-Enable-the-exposed_provenance-feature.patch

-22
This file was deleted.

src/intrinsics/simd.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,35 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
822822
let (lane_count, lane_ty) = a.layout().ty.simd_size_and_type(fx.tcx);
823823
let lane_layout = fx.layout_of(lane_ty);
824824

825-
let m = m.load_scalar(fx);
825+
let expected_int_bits = lane_count.max(8);
826+
let expected_bytes = expected_int_bits / 8 + ((expected_int_bits % 8 > 0) as u64);
827+
828+
let m = match m.layout().ty.kind() {
829+
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => m.load_scalar(fx),
830+
ty::Array(elem, len)
831+
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
832+
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
833+
== Some(expected_bytes) =>
834+
{
835+
m.force_stack(fx).0.load(
836+
fx,
837+
Type::int(expected_int_bits as u16).unwrap(),
838+
MemFlags::trusted(),
839+
)
840+
}
841+
_ => {
842+
fx.tcx.dcx().span_fatal(
843+
span,
844+
format!(
845+
"invalid monomorphization of `simd_select_bitmask` intrinsic: \
846+
cannot accept `{}` as mask, expected `u{}` or `[u8; {}]`",
847+
ret.layout().ty,
848+
expected_int_bits,
849+
expected_bytes
850+
),
851+
);
852+
}
853+
};
826854

827855
for lane in 0..lane_count {
828856
let m_lane = fx.bcx.ins().ushr_imm(m, u64::from(lane) as i64);

0 commit comments

Comments
 (0)