Skip to content

Commit d5fa08c

Browse files
committed
Auto merge of rust-lang#3659 - RalfJung:bitmask-too-large, r=RalfJung
simd_bitmask: nicer error when the mask is too big Cc rust-lang/miri#3658
2 parents 989dfb1 + a13a9ab commit d5fa08c

File tree

1 file changed

+10
-2
lines changed
  • src/tools/miri/src/intrinsics

1 file changed

+10
-2
lines changed

src/tools/miri/src/intrinsics/simd.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
452452
let (no, no_len) = this.operand_to_simd(no)?;
453453
let (dest, dest_len) = this.mplace_to_simd(dest)?;
454454
let bitmask_len = dest_len.next_multiple_of(8);
455+
if bitmask_len > 64 {
456+
throw_unsup_format!(
457+
"simd_bitmask: masks larger than 64 elements are currently not supported"
458+
);
459+
}
455460

456461
// The mask must be an integer or an array.
457462
assert!(
458463
mask.layout.ty.is_integral()
459464
|| matches!(mask.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8)
460465
);
461-
assert!(bitmask_len <= 64);
462466
assert_eq!(bitmask_len, mask.layout.size.bits());
463467
assert_eq!(dest_len, yes_len);
464468
assert_eq!(dest_len, no_len);
@@ -498,13 +502,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
498502
let [op] = check_arg_count(args)?;
499503
let (op, op_len) = this.operand_to_simd(op)?;
500504
let bitmask_len = op_len.next_multiple_of(8);
505+
if bitmask_len > 64 {
506+
throw_unsup_format!(
507+
"simd_bitmask: masks larger than 64 elements are currently not supported"
508+
);
509+
}
501510

502511
// Returns either an unsigned integer or array of `u8`.
503512
assert!(
504513
dest.layout.ty.is_integral()
505514
|| matches!(dest.layout.ty.kind(), ty::Array(elemty, _) if elemty == &this.tcx.types.u8)
506515
);
507-
assert!(bitmask_len <= 64);
508516
assert_eq!(bitmask_len, dest.layout.size.bits());
509517
let op_len = u32::try_from(op_len).unwrap();
510518

0 commit comments

Comments
 (0)