Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4a9657

Browse files
committedSep 13, 2024·
interpret: simplify SIMD type handling
1 parent a9fb00b commit d4a9657

File tree

15 files changed

+188
-197
lines changed

15 files changed

+188
-197
lines changed
 

‎compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
384384
sym::simd_insert => {
385385
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
386386
let elem = &args[2];
387-
let (input, input_len) = self.operand_to_simd(&args[0])?;
388-
let (dest, dest_len) = self.mplace_to_simd(dest)?;
387+
let (input, input_len) = self.project_to_simd(&args[0])?;
388+
let (dest, dest_len) = self.project_to_simd(dest)?;
389389
assert_eq!(input_len, dest_len, "Return vector length must match input length");
390390
// Bounds are not checked by typeck so we have to do it ourselves.
391391
if index >= input_len {
@@ -406,7 +406,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
406406
}
407407
sym::simd_extract => {
408408
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
409-
let (input, input_len) = self.operand_to_simd(&args[0])?;
409+
let (input, input_len) = self.project_to_simd(&args[0])?;
410410
// Bounds are not checked by typeck so we have to do it ourselves.
411411
if index >= input_len {
412412
throw_ub_format!(

‎compiler/rustc_const_eval/src/interpret/operand.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -679,30 +679,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
679679
Ok(str)
680680
}
681681

682-
/// Converts a repr(simd) operand into an operand where `place_index` accesses the SIMD elements.
683-
/// Also returns the number of elements.
684-
///
685-
/// Can (but does not always) trigger UB if `op` is uninitialized.
686-
pub fn operand_to_simd(
687-
&self,
688-
op: &OpTy<'tcx, M::Provenance>,
689-
) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::Provenance>, u64)> {
690-
// Basically we just transmute this place into an array following simd_size_and_type.
691-
// This only works in memory, but repr(simd) types should never be immediates anyway.
692-
assert!(op.layout.ty.is_simd());
693-
match op.as_mplace_or_imm() {
694-
Left(mplace) => self.mplace_to_simd(&mplace),
695-
Right(imm) => match *imm {
696-
Immediate::Uninit => {
697-
throw_ub!(InvalidUninitBytes(None))
698-
}
699-
Immediate::Scalar(..) | Immediate::ScalarPair(..) => {
700-
bug!("arrays/slices can never have Scalar/ScalarPair layout")
701-
}
702-
},
703-
}
704-
}
705-
706682
/// Read from a local of the current frame.
707683
/// Will not access memory, instead an indirect `Operand` is returned.
708684
///

‎compiler/rustc_const_eval/src/interpret/place.rs

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,15 @@ where
375375
Prov: Provenance,
376376
M: Machine<'tcx, Provenance = Prov>,
377377
{
378-
pub fn ptr_with_meta_to_mplace(
378+
fn ptr_with_meta_to_mplace(
379379
&self,
380380
ptr: Pointer<Option<M::Provenance>>,
381381
meta: MemPlaceMeta<M::Provenance>,
382382
layout: TyAndLayout<'tcx>,
383+
unaligned: bool,
383384
) -> MPlaceTy<'tcx, M::Provenance> {
384-
let misaligned = self.is_ptr_misaligned(ptr, layout.align.abi);
385+
let misaligned =
386+
if unaligned { None } else { self.is_ptr_misaligned(ptr, layout.align.abi) };
385387
MPlaceTy { mplace: MemPlace { ptr, meta, misaligned }, layout }
386388
}
387389

@@ -391,7 +393,16 @@ where
391393
layout: TyAndLayout<'tcx>,
392394
) -> MPlaceTy<'tcx, M::Provenance> {
393395
assert!(layout.is_sized());
394-
self.ptr_with_meta_to_mplace(ptr, MemPlaceMeta::None, layout)
396+
self.ptr_with_meta_to_mplace(ptr, MemPlaceMeta::None, layout, /*unaligned*/ false)
397+
}
398+
399+
pub fn ptr_to_mplace_unaligned(
400+
&self,
401+
ptr: Pointer<Option<M::Provenance>>,
402+
layout: TyAndLayout<'tcx>,
403+
) -> MPlaceTy<'tcx, M::Provenance> {
404+
assert!(layout.is_sized());
405+
self.ptr_with_meta_to_mplace(ptr, MemPlaceMeta::None, layout, /*unaligned*/ true)
395406
}
396407

397408
/// Take a value, which represents a (thin or wide) reference, and make it a place.
@@ -412,7 +423,7 @@ where
412423
// `ref_to_mplace` is called on raw pointers even if they don't actually get dereferenced;
413424
// we hence can't call `size_and_align_of` since that asserts more validity than we want.
414425
let ptr = ptr.to_pointer(self)?;
415-
Ok(self.ptr_with_meta_to_mplace(ptr, meta, layout))
426+
Ok(self.ptr_with_meta_to_mplace(ptr, meta, layout, /*unaligned*/ false))
416427
}
417428

418429
/// Turn a mplace into a (thin or wide) mutable raw pointer, pointing to the same space.
@@ -482,23 +493,6 @@ where
482493
Ok(a)
483494
}
484495

485-
/// Converts a repr(simd) place into a place where `place_index` accesses the SIMD elements.
486-
/// Also returns the number of elements.
487-
pub fn mplace_to_simd(
488-
&self,
489-
mplace: &MPlaceTy<'tcx, M::Provenance>,
490-
) -> InterpResult<'tcx, (MPlaceTy<'tcx, M::Provenance>, u64)> {
491-
// Basically we want to transmute this place into an array following simd_size_and_type.
492-
let (len, e_ty) = mplace.layout.ty.simd_size_and_type(*self.tcx);
493-
// Some SIMD types have padding, so `len` many `e_ty` does not cover the entire place.
494-
// Therefore we cannot transmute, and instead we project at offset 0, which side-steps
495-
// the size check.
496-
let array_layout = self.layout_of(Ty::new_array(self.tcx.tcx, e_ty, len))?;
497-
assert!(array_layout.size <= mplace.layout.size);
498-
let mplace = mplace.offset(Size::ZERO, array_layout, self)?;
499-
Ok((mplace, len))
500-
}
501-
502496
/// Turn a local in the current frame into a place.
503497
pub fn local_to_place(
504498
&self,
@@ -983,7 +977,7 @@ where
983977
span_bug!(self.cur_span(), "cannot allocate space for `extern` type, size is not known")
984978
};
985979
let ptr = self.allocate_ptr(size, align, kind)?;
986-
Ok(self.ptr_with_meta_to_mplace(ptr.into(), meta, layout))
980+
Ok(self.ptr_with_meta_to_mplace(ptr.into(), meta, layout, /*unaligned*/ false))
987981
}
988982

989983
pub fn allocate(
@@ -1018,7 +1012,12 @@ where
10181012
};
10191013
let meta = Scalar::from_target_usize(u64::try_from(str.len()).unwrap(), self);
10201014
let layout = self.layout_of(self.tcx.types.str_).unwrap();
1021-
Ok(self.ptr_with_meta_to_mplace(ptr.into(), MemPlaceMeta::Meta(meta), layout))
1015+
Ok(self.ptr_with_meta_to_mplace(
1016+
ptr.into(),
1017+
MemPlaceMeta::Meta(meta),
1018+
layout,
1019+
/*unaligned*/ false,
1020+
))
10221021
}
10231022

10241023
pub fn raw_const_to_mplace(

‎compiler/rustc_const_eval/src/interpret/projection.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ where
244244
base.offset(offset, field_layout, self)
245245
}
246246

247+
/// Converts a repr(simd) value into an array of the right size, such that `project_index`
248+
/// accesses the SIMD elements. Also returns the number of elements.
249+
pub fn project_to_simd<P: Projectable<'tcx, M::Provenance>>(
250+
&self,
251+
base: &P,
252+
) -> InterpResult<'tcx, (P, u64)> {
253+
assert!(base.layout().ty.ty_adt_def().unwrap().repr().simd());
254+
// SIMD types must be newtypes around arrays, so all we have to do is project to their only field.
255+
let array = self.project_field(base, 0)?;
256+
let len = array.len(self)?;
257+
Ok((array, len))
258+
}
259+
247260
fn project_constant_index<P: Projectable<'tcx, M::Provenance>>(
248261
&self,
249262
base: &P,

‎compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::ty::{
99
};
1010
use tracing::debug;
1111

12-
use super::{throw_inval, InterpCx, MPlaceTy, MemPlaceMeta, MemoryKind};
12+
use super::{throw_inval, InterpCx, MPlaceTy, MemoryKind};
1313
use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationResult};
1414

1515
/// Checks whether a type contains generic parameters which must be instantiated.
@@ -103,5 +103,5 @@ pub(crate) fn create_static_alloc<'tcx>(
103103
assert_eq!(ecx.machine.static_root_ids, None);
104104
ecx.machine.static_root_ids = Some((alloc_id, static_def_id));
105105
assert!(ecx.memory.alloc_map.insert(alloc_id, (MemoryKind::Stack, alloc)).is_none());
106-
Ok(ecx.ptr_with_meta_to_mplace(Pointer::from(alloc_id).into(), MemPlaceMeta::None, layout))
106+
Ok(ecx.ptr_to_mplace(Pointer::from(alloc_id).into(), layout))
107107
}

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5050
| "bitreverse"
5151
=> {
5252
let [op] = check_arg_count(args)?;
53-
let (op, op_len) = this.operand_to_simd(op)?;
54-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
53+
let (op, op_len) = this.project_to_simd(op)?;
54+
let (dest, dest_len) = this.project_to_simd(dest)?;
5555

5656
assert_eq!(dest_len, op_len);
5757

@@ -200,9 +200,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
200200
use mir::BinOp;
201201

202202
let [left, right] = check_arg_count(args)?;
203-
let (left, left_len) = this.operand_to_simd(left)?;
204-
let (right, right_len) = this.operand_to_simd(right)?;
205-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
203+
let (left, left_len) = this.project_to_simd(left)?;
204+
let (right, right_len) = this.project_to_simd(right)?;
205+
let (dest, dest_len) = this.project_to_simd(dest)?;
206206

207207
assert_eq!(dest_len, left_len);
208208
assert_eq!(dest_len, right_len);
@@ -291,10 +291,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
291291
}
292292
"fma" => {
293293
let [a, b, c] = check_arg_count(args)?;
294-
let (a, a_len) = this.operand_to_simd(a)?;
295-
let (b, b_len) = this.operand_to_simd(b)?;
296-
let (c, c_len) = this.operand_to_simd(c)?;
297-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
294+
let (a, a_len) = this.project_to_simd(a)?;
295+
let (b, b_len) = this.project_to_simd(b)?;
296+
let (c, c_len) = this.project_to_simd(c)?;
297+
let (dest, dest_len) = this.project_to_simd(dest)?;
298298

299299
assert_eq!(dest_len, a_len);
300300
assert_eq!(dest_len, b_len);
@@ -345,7 +345,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
345345
use mir::BinOp;
346346

347347
let [op] = check_arg_count(args)?;
348-
let (op, op_len) = this.operand_to_simd(op)?;
348+
let (op, op_len) = this.project_to_simd(op)?;
349349

350350
let imm_from_bool =
351351
|b| ImmTy::from_scalar(Scalar::from_bool(b), this.machine.layouts.bool);
@@ -408,7 +408,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
408408
use mir::BinOp;
409409

410410
let [op, init] = check_arg_count(args)?;
411-
let (op, op_len) = this.operand_to_simd(op)?;
411+
let (op, op_len) = this.project_to_simd(op)?;
412412
let init = this.read_immediate(init)?;
413413

414414
let mir_op = match intrinsic_name {
@@ -426,10 +426,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
426426
}
427427
"select" => {
428428
let [mask, yes, no] = check_arg_count(args)?;
429-
let (mask, mask_len) = this.operand_to_simd(mask)?;
430-
let (yes, yes_len) = this.operand_to_simd(yes)?;
431-
let (no, no_len) = this.operand_to_simd(no)?;
432-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
429+
let (mask, mask_len) = this.project_to_simd(mask)?;
430+
let (yes, yes_len) = this.project_to_simd(yes)?;
431+
let (no, no_len) = this.project_to_simd(no)?;
432+
let (dest, dest_len) = this.project_to_simd(dest)?;
433433

434434
assert_eq!(dest_len, mask_len);
435435
assert_eq!(dest_len, yes_len);
@@ -448,9 +448,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
448448
// Variant of `select` that takes a bitmask rather than a "vector of bool".
449449
"select_bitmask" => {
450450
let [mask, yes, no] = check_arg_count(args)?;
451-
let (yes, yes_len) = this.operand_to_simd(yes)?;
452-
let (no, no_len) = this.operand_to_simd(no)?;
453-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
451+
let (yes, yes_len) = this.project_to_simd(yes)?;
452+
let (no, no_len) = this.project_to_simd(no)?;
453+
let (dest, dest_len) = this.project_to_simd(dest)?;
454454
let bitmask_len = dest_len.next_multiple_of(8);
455455
if bitmask_len > 64 {
456456
throw_unsup_format!(
@@ -522,7 +522,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
522522
// Converts a "vector of bool" into a bitmask.
523523
"bitmask" => {
524524
let [op] = check_arg_count(args)?;
525-
let (op, op_len) = this.operand_to_simd(op)?;
525+
let (op, op_len) = this.project_to_simd(op)?;
526526
let bitmask_len = op_len.next_multiple_of(8);
527527
if bitmask_len > 64 {
528528
throw_unsup_format!(
@@ -570,8 +570,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
570570
}
571571
"cast" | "as" | "cast_ptr" | "expose_provenance" | "with_exposed_provenance" => {
572572
let [op] = check_arg_count(args)?;
573-
let (op, op_len) = this.operand_to_simd(op)?;
574-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
573+
let (op, op_len) = this.project_to_simd(op)?;
574+
let (dest, dest_len) = this.project_to_simd(dest)?;
575575

576576
assert_eq!(dest_len, op_len);
577577

@@ -627,9 +627,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
627627
}
628628
"shuffle_generic" => {
629629
let [left, right] = check_arg_count(args)?;
630-
let (left, left_len) = this.operand_to_simd(left)?;
631-
let (right, right_len) = this.operand_to_simd(right)?;
632-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
630+
let (left, left_len) = this.project_to_simd(left)?;
631+
let (right, right_len) = this.project_to_simd(right)?;
632+
let (dest, dest_len) = this.project_to_simd(dest)?;
633633

634634
let index = generic_args[2]
635635
.expect_const()
@@ -662,9 +662,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
662662
}
663663
"shuffle" => {
664664
let [left, right, index] = check_arg_count(args)?;
665-
let (left, left_len) = this.operand_to_simd(left)?;
666-
let (right, right_len) = this.operand_to_simd(right)?;
667-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
665+
let (left, left_len) = this.project_to_simd(left)?;
666+
let (right, right_len) = this.project_to_simd(right)?;
667+
let (dest, dest_len) = this.project_to_simd(dest)?;
668668

669669
// `index` is an array, not a SIMD type
670670
let ty::Array(_, index_len) = index.layout.ty.kind() else {
@@ -702,10 +702,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
702702
}
703703
"gather" => {
704704
let [passthru, ptrs, mask] = check_arg_count(args)?;
705-
let (passthru, passthru_len) = this.operand_to_simd(passthru)?;
706-
let (ptrs, ptrs_len) = this.operand_to_simd(ptrs)?;
707-
let (mask, mask_len) = this.operand_to_simd(mask)?;
708-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
705+
let (passthru, passthru_len) = this.project_to_simd(passthru)?;
706+
let (ptrs, ptrs_len) = this.project_to_simd(ptrs)?;
707+
let (mask, mask_len) = this.project_to_simd(mask)?;
708+
let (dest, dest_len) = this.project_to_simd(dest)?;
709709

710710
assert_eq!(dest_len, passthru_len);
711711
assert_eq!(dest_len, ptrs_len);
@@ -728,9 +728,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
728728
}
729729
"scatter" => {
730730
let [value, ptrs, mask] = check_arg_count(args)?;
731-
let (value, value_len) = this.operand_to_simd(value)?;
732-
let (ptrs, ptrs_len) = this.operand_to_simd(ptrs)?;
733-
let (mask, mask_len) = this.operand_to_simd(mask)?;
731+
let (value, value_len) = this.project_to_simd(value)?;
732+
let (ptrs, ptrs_len) = this.project_to_simd(ptrs)?;
733+
let (mask, mask_len) = this.project_to_simd(mask)?;
734734

735735
assert_eq!(ptrs_len, value_len);
736736
assert_eq!(ptrs_len, mask_len);
@@ -748,10 +748,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
748748
}
749749
"masked_load" => {
750750
let [mask, ptr, default] = check_arg_count(args)?;
751-
let (mask, mask_len) = this.operand_to_simd(mask)?;
751+
let (mask, mask_len) = this.project_to_simd(mask)?;
752752
let ptr = this.read_pointer(ptr)?;
753-
let (default, default_len) = this.operand_to_simd(default)?;
754-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
753+
let (default, default_len) = this.project_to_simd(default)?;
754+
let (dest, dest_len) = this.project_to_simd(dest)?;
755755

756756
assert_eq!(dest_len, mask_len);
757757
assert_eq!(dest_len, default_len);
@@ -775,9 +775,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
775775
}
776776
"masked_store" => {
777777
let [mask, ptr, vals] = check_arg_count(args)?;
778-
let (mask, mask_len) = this.operand_to_simd(mask)?;
778+
let (mask, mask_len) = this.project_to_simd(mask)?;
779779
let ptr = this.read_pointer(ptr)?;
780-
let (vals, vals_len) = this.operand_to_simd(vals)?;
780+
let (vals, vals_len) = this.project_to_simd(vals)?;
781781

782782
assert_eq!(mask_len, vals_len);
783783

‎src/tools/miri/src/shims/foreign_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
903903
name if name.starts_with("llvm.ctpop.v") => {
904904
let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
905905

906-
let (op, op_len) = this.operand_to_simd(op)?;
907-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
906+
let (op, op_len) = this.project_to_simd(op)?;
907+
let (dest, dest_len) = this.project_to_simd(dest)?;
908908

909909
assert_eq!(dest_len, op_len);
910910

‎src/tools/miri/src/shims/x86/avx.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
159159
let [data, control] =
160160
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
161161

162-
let (data, data_len) = this.operand_to_simd(data)?;
163-
let (control, control_len) = this.operand_to_simd(control)?;
164-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
162+
let (data, data_len) = this.project_to_simd(data)?;
163+
let (control, control_len) = this.project_to_simd(control)?;
164+
let (dest, dest_len) = this.project_to_simd(dest)?;
165165

166166
assert_eq!(dest_len, data_len);
167167
assert_eq!(dest_len, control_len);
@@ -193,9 +193,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
193193
let [data, control] =
194194
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
195195

196-
let (data, data_len) = this.operand_to_simd(data)?;
197-
let (control, control_len) = this.operand_to_simd(control)?;
198-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
196+
let (data, data_len) = this.project_to_simd(data)?;
197+
let (control, control_len) = this.project_to_simd(control)?;
198+
let (dest, dest_len) = this.project_to_simd(dest)?;
199199

200200
assert_eq!(dest_len, data_len);
201201
assert_eq!(dest_len, control_len);

‎src/tools/miri/src/shims/x86/avx2.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6262

6363
assert_eq!(dest.layout, src.layout);
6464

65-
let (src, _) = this.operand_to_simd(src)?;
66-
let (offsets, offsets_len) = this.operand_to_simd(offsets)?;
67-
let (mask, mask_len) = this.operand_to_simd(mask)?;
68-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
65+
let (src, _) = this.project_to_simd(src)?;
66+
let (offsets, offsets_len) = this.project_to_simd(offsets)?;
67+
let (mask, mask_len) = this.project_to_simd(mask)?;
68+
let (dest, dest_len) = this.project_to_simd(dest)?;
6969

7070
// There are cases like dest: i32x4, offsets: i64x2
7171
// If dest has more elements than offset, extra dest elements are filled with zero.
@@ -118,9 +118,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
118118
let [left, right] =
119119
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
120120

121-
let (left, left_len) = this.operand_to_simd(left)?;
122-
let (right, right_len) = this.operand_to_simd(right)?;
123-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
121+
let (left, left_len) = this.project_to_simd(left)?;
122+
let (right, right_len) = this.project_to_simd(right)?;
123+
let (dest, dest_len) = this.project_to_simd(dest)?;
124124

125125
assert_eq!(left_len, right_len);
126126
assert_eq!(dest_len.strict_mul(2), left_len);
@@ -155,9 +155,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
155155
let [left, right] =
156156
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
157157

158-
let (left, left_len) = this.operand_to_simd(left)?;
159-
let (right, right_len) = this.operand_to_simd(right)?;
160-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
158+
let (left, left_len) = this.project_to_simd(left)?;
159+
let (right, right_len) = this.project_to_simd(right)?;
160+
let (dest, dest_len) = this.project_to_simd(dest)?;
161161

162162
assert_eq!(left_len, right_len);
163163
assert_eq!(dest_len.strict_mul(2), left_len);
@@ -271,9 +271,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
271271
let [left, right] =
272272
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
273273

274-
let (left, left_len) = this.operand_to_simd(left)?;
275-
let (right, right_len) = this.operand_to_simd(right)?;
276-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
274+
let (left, left_len) = this.project_to_simd(left)?;
275+
let (right, right_len) = this.project_to_simd(right)?;
276+
let (dest, dest_len) = this.project_to_simd(dest)?;
277277

278278
assert_eq!(dest_len, left_len);
279279
assert_eq!(dest_len, right_len);
@@ -330,9 +330,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
330330
let [left, right] =
331331
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
332332

333-
let (left, left_len) = this.operand_to_simd(left)?;
334-
let (right, right_len) = this.operand_to_simd(right)?;
335-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
333+
let (left, left_len) = this.project_to_simd(left)?;
334+
let (right, right_len) = this.project_to_simd(right)?;
335+
let (dest, dest_len) = this.project_to_simd(dest)?;
336336

337337
assert_eq!(left_len, right_len);
338338
assert_eq!(left_len, dest_len.strict_mul(8));
@@ -363,9 +363,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
363363
let [left, right] =
364364
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
365365

366-
let (left, left_len) = this.operand_to_simd(left)?;
367-
let (right, right_len) = this.operand_to_simd(right)?;
368-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
366+
let (left, left_len) = this.project_to_simd(left)?;
367+
let (right, right_len) = this.project_to_simd(right)?;
368+
let (dest, dest_len) = this.project_to_simd(dest)?;
369369

370370
assert_eq!(dest_len, left_len);
371371
assert_eq!(dest_len, right_len);

‎src/tools/miri/src/shims/x86/mod.rs

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,9 @@ fn bin_op_simd_float_first<'tcx, F: rustc_apfloat::Float>(
314314
right: &OpTy<'tcx>,
315315
dest: &MPlaceTy<'tcx>,
316316
) -> InterpResult<'tcx, ()> {
317-
let (left, left_len) = this.operand_to_simd(left)?;
318-
let (right, right_len) = this.operand_to_simd(right)?;
319-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
317+
let (left, left_len) = this.project_to_simd(left)?;
318+
let (right, right_len) = this.project_to_simd(right)?;
319+
let (dest, dest_len) = this.project_to_simd(dest)?;
320320

321321
assert_eq!(dest_len, left_len);
322322
assert_eq!(dest_len, right_len);
@@ -344,9 +344,9 @@ fn bin_op_simd_float_all<'tcx, F: rustc_apfloat::Float>(
344344
right: &OpTy<'tcx>,
345345
dest: &MPlaceTy<'tcx>,
346346
) -> InterpResult<'tcx, ()> {
347-
let (left, left_len) = this.operand_to_simd(left)?;
348-
let (right, right_len) = this.operand_to_simd(right)?;
349-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
347+
let (left, left_len) = this.project_to_simd(left)?;
348+
let (right, right_len) = this.project_to_simd(right)?;
349+
let (dest, dest_len) = this.project_to_simd(dest)?;
350350

351351
assert_eq!(dest_len, left_len);
352352
assert_eq!(dest_len, right_len);
@@ -430,8 +430,8 @@ fn unary_op_ss<'tcx>(
430430
op: &OpTy<'tcx>,
431431
dest: &MPlaceTy<'tcx>,
432432
) -> InterpResult<'tcx, ()> {
433-
let (op, op_len) = this.operand_to_simd(op)?;
434-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
433+
let (op, op_len) = this.project_to_simd(op)?;
434+
let (dest, dest_len) = this.project_to_simd(dest)?;
435435

436436
assert_eq!(dest_len, op_len);
437437

@@ -453,8 +453,8 @@ fn unary_op_ps<'tcx>(
453453
op: &OpTy<'tcx>,
454454
dest: &MPlaceTy<'tcx>,
455455
) -> InterpResult<'tcx, ()> {
456-
let (op, op_len) = this.operand_to_simd(op)?;
457-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
456+
let (op, op_len) = this.project_to_simd(op)?;
457+
let (dest, dest_len) = this.project_to_simd(dest)?;
458458

459459
assert_eq!(dest_len, op_len);
460460

@@ -491,8 +491,8 @@ fn shift_simd_by_scalar<'tcx>(
491491
which: ShiftOp,
492492
dest: &MPlaceTy<'tcx>,
493493
) -> InterpResult<'tcx, ()> {
494-
let (left, left_len) = this.operand_to_simd(left)?;
495-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
494+
let (left, left_len) = this.project_to_simd(left)?;
495+
let (dest, dest_len) = this.project_to_simd(dest)?;
496496

497497
assert_eq!(dest_len, left_len);
498498
// `right` may have a different length, and we only care about its
@@ -547,9 +547,9 @@ fn shift_simd_by_simd<'tcx>(
547547
which: ShiftOp,
548548
dest: &MPlaceTy<'tcx>,
549549
) -> InterpResult<'tcx, ()> {
550-
let (left, left_len) = this.operand_to_simd(left)?;
551-
let (right, right_len) = this.operand_to_simd(right)?;
552-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
550+
let (left, left_len) = this.project_to_simd(left)?;
551+
let (right, right_len) = this.project_to_simd(right)?;
552+
let (dest, dest_len) = this.project_to_simd(dest)?;
553553

554554
assert_eq!(dest_len, left_len);
555555
assert_eq!(dest_len, right_len);
@@ -613,9 +613,9 @@ fn round_first<'tcx, F: rustc_apfloat::Float>(
613613
rounding: &OpTy<'tcx>,
614614
dest: &MPlaceTy<'tcx>,
615615
) -> InterpResult<'tcx, ()> {
616-
let (left, left_len) = this.operand_to_simd(left)?;
617-
let (right, right_len) = this.operand_to_simd(right)?;
618-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
616+
let (left, left_len) = this.project_to_simd(left)?;
617+
let (right, right_len) = this.project_to_simd(right)?;
618+
let (dest, dest_len) = this.project_to_simd(dest)?;
619619

620620
assert_eq!(dest_len, left_len);
621621
assert_eq!(dest_len, right_len);
@@ -643,8 +643,8 @@ fn round_all<'tcx, F: rustc_apfloat::Float>(
643643
rounding: &OpTy<'tcx>,
644644
dest: &MPlaceTy<'tcx>,
645645
) -> InterpResult<'tcx, ()> {
646-
let (op, op_len) = this.operand_to_simd(op)?;
647-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
646+
let (op, op_len) = this.project_to_simd(op)?;
647+
let (dest, dest_len) = this.project_to_simd(dest)?;
648648

649649
assert_eq!(dest_len, op_len);
650650

@@ -695,8 +695,8 @@ fn convert_float_to_int<'tcx>(
695695
rnd: rustc_apfloat::Round,
696696
dest: &MPlaceTy<'tcx>,
697697
) -> InterpResult<'tcx, ()> {
698-
let (op, op_len) = this.operand_to_simd(op)?;
699-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
698+
let (op, op_len) = this.project_to_simd(op)?;
699+
let (dest, dest_len) = this.project_to_simd(dest)?;
700700

701701
// Output must be *signed* integers.
702702
assert!(matches!(dest.layout.field(this, 0).ty.kind(), ty::Int(_)));
@@ -729,8 +729,8 @@ fn int_abs<'tcx>(
729729
op: &OpTy<'tcx>,
730730
dest: &MPlaceTy<'tcx>,
731731
) -> InterpResult<'tcx, ()> {
732-
let (op, op_len) = this.operand_to_simd(op)?;
733-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
732+
let (op, op_len) = this.project_to_simd(op)?;
733+
let (dest, dest_len) = this.project_to_simd(dest)?;
734734

735735
assert_eq!(op_len, dest_len);
736736

@@ -906,8 +906,8 @@ fn test_bits_masked<'tcx>(
906906
) -> InterpResult<'tcx, (bool, bool)> {
907907
assert_eq!(op.layout, mask.layout);
908908

909-
let (op, op_len) = this.operand_to_simd(op)?;
910-
let (mask, mask_len) = this.operand_to_simd(mask)?;
909+
let (op, op_len) = this.project_to_simd(op)?;
910+
let (mask, mask_len) = this.project_to_simd(mask)?;
911911

912912
assert_eq!(op_len, mask_len);
913913

@@ -937,8 +937,8 @@ fn test_high_bits_masked<'tcx>(
937937
) -> InterpResult<'tcx, (bool, bool)> {
938938
assert_eq!(op.layout, mask.layout);
939939

940-
let (op, op_len) = this.operand_to_simd(op)?;
941-
let (mask, mask_len) = this.operand_to_simd(mask)?;
940+
let (op, op_len) = this.project_to_simd(op)?;
941+
let (mask, mask_len) = this.project_to_simd(mask)?;
942942

943943
assert_eq!(op_len, mask_len);
944944

@@ -967,8 +967,8 @@ fn mask_load<'tcx>(
967967
mask: &OpTy<'tcx>,
968968
dest: &MPlaceTy<'tcx>,
969969
) -> InterpResult<'tcx, ()> {
970-
let (mask, mask_len) = this.operand_to_simd(mask)?;
971-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
970+
let (mask, mask_len) = this.project_to_simd(mask)?;
971+
let (dest, dest_len) = this.project_to_simd(dest)?;
972972

973973
assert_eq!(dest_len, mask_len);
974974

@@ -1000,8 +1000,8 @@ fn mask_store<'tcx>(
10001000
mask: &OpTy<'tcx>,
10011001
value: &OpTy<'tcx>,
10021002
) -> InterpResult<'tcx, ()> {
1003-
let (mask, mask_len) = this.operand_to_simd(mask)?;
1004-
let (value, value_len) = this.operand_to_simd(value)?;
1003+
let (mask, mask_len) = this.project_to_simd(mask)?;
1004+
let (value, value_len) = this.project_to_simd(value)?;
10051005

10061006
assert_eq!(value_len, mask_len);
10071007

@@ -1014,9 +1014,12 @@ fn mask_store<'tcx>(
10141014
let value = this.project_index(&value, i)?;
10151015

10161016
if this.read_scalar(&mask)?.to_uint(mask_item_size)? >> high_bit_offset != 0 {
1017+
// *Non-inbounds* pointer arithmetic to compute the destination.
1018+
// (That's why we can't use a place projection.)
10171019
let ptr = ptr.wrapping_offset(value.layout.size * i, &this.tcx);
1018-
// Unaligned copy, which is what we want.
1019-
this.mem_copy(value.ptr(), ptr, value.layout.size, /*nonoverlapping*/ true)?;
1020+
// Deref the pointer *unaligned*, and do the copy.
1021+
let dest = this.ptr_to_mplace_unaligned(ptr, value.layout);
1022+
this.copy_op(&value, &dest)?;
10201023
}
10211024
}
10221025

@@ -1095,9 +1098,9 @@ fn pmulhrsw<'tcx>(
10951098
right: &OpTy<'tcx>,
10961099
dest: &MPlaceTy<'tcx>,
10971100
) -> InterpResult<'tcx, ()> {
1098-
let (left, left_len) = this.operand_to_simd(left)?;
1099-
let (right, right_len) = this.operand_to_simd(right)?;
1100-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
1101+
let (left, left_len) = this.project_to_simd(left)?;
1102+
let (right, right_len) = this.project_to_simd(right)?;
1103+
let (dest, dest_len) = this.project_to_simd(dest)?;
11011104

11021105
assert_eq!(dest_len, left_len);
11031106
assert_eq!(dest_len, right_len);
@@ -1313,9 +1316,9 @@ fn psign<'tcx>(
13131316
right: &OpTy<'tcx>,
13141317
dest: &MPlaceTy<'tcx>,
13151318
) -> InterpResult<'tcx, ()> {
1316-
let (left, left_len) = this.operand_to_simd(left)?;
1317-
let (right, right_len) = this.operand_to_simd(right)?;
1318-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
1319+
let (left, left_len) = this.project_to_simd(left)?;
1320+
let (right, right_len) = this.project_to_simd(right)?;
1321+
let (dest, dest_len) = this.project_to_simd(dest)?;
13191322

13201323
assert_eq!(dest_len, left_len);
13211324
assert_eq!(dest_len, right_len);

‎src/tools/miri/src/shims/x86/sha.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2323
// Prefix should have already been checked.
2424
let unprefixed_name = link_name.as_str().strip_prefix("llvm.x86.sha").unwrap();
2525

26-
fn read<'c>(this: &mut MiriInterpCx<'c>, reg: &MPlaceTy<'c>) -> InterpResult<'c, [u32; 4]> {
26+
fn read<'c>(this: &mut MiriInterpCx<'c>, reg: &OpTy<'c>) -> InterpResult<'c, [u32; 4]> {
2727
let mut res = [0; 4];
2828
// We reverse the order because x86 is little endian but the copied implementation uses
2929
// big endian.
@@ -53,10 +53,10 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5353
"256rnds2" => {
5454
let [a, b, k] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
5555

56-
let (a_reg, a_len) = this.operand_to_simd(a)?;
57-
let (b_reg, b_len) = this.operand_to_simd(b)?;
58-
let (k_reg, k_len) = this.operand_to_simd(k)?;
59-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
56+
let (a_reg, a_len) = this.project_to_simd(a)?;
57+
let (b_reg, b_len) = this.project_to_simd(b)?;
58+
let (k_reg, k_len) = this.project_to_simd(k)?;
59+
let (dest, dest_len) = this.project_to_simd(dest)?;
6060

6161
assert_eq!(a_len, 4);
6262
assert_eq!(b_len, 4);
@@ -74,9 +74,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
7474
"256msg1" => {
7575
let [a, b] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
7676

77-
let (a_reg, a_len) = this.operand_to_simd(a)?;
78-
let (b_reg, b_len) = this.operand_to_simd(b)?;
79-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
77+
let (a_reg, a_len) = this.project_to_simd(a)?;
78+
let (b_reg, b_len) = this.project_to_simd(b)?;
79+
let (dest, dest_len) = this.project_to_simd(dest)?;
8080

8181
assert_eq!(a_len, 4);
8282
assert_eq!(b_len, 4);
@@ -92,9 +92,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
9292
"256msg2" => {
9393
let [a, b] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
9494

95-
let (a_reg, a_len) = this.operand_to_simd(a)?;
96-
let (b_reg, b_len) = this.operand_to_simd(b)?;
97-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
95+
let (a_reg, a_len) = this.project_to_simd(a)?;
96+
let (b_reg, b_len) = this.project_to_simd(b)?;
97+
let (dest, dest_len) = this.project_to_simd(dest)?;
9898

9999
assert_eq!(a_len, 4);
100100
assert_eq!(b_len, 4);

‎src/tools/miri/src/shims/x86/sse.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
130130
let [left, right] =
131131
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
132132

133-
let (left, left_len) = this.operand_to_simd(left)?;
134-
let (right, right_len) = this.operand_to_simd(right)?;
133+
let (left, left_len) = this.project_to_simd(left)?;
134+
let (right, right_len) = this.project_to_simd(right)?;
135135

136136
assert_eq!(left_len, right_len);
137137

@@ -157,7 +157,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
157157
// Converts the first component of `op` from f32 to i32/i64.
158158
"cvtss2si" | "cvttss2si" | "cvtss2si64" | "cvttss2si64" => {
159159
let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
160-
let (op, _) = this.operand_to_simd(op)?;
160+
let (op, _) = this.project_to_simd(op)?;
161161

162162
let op = this.read_immediate(&this.project_index(&op, 0)?)?;
163163

@@ -187,8 +187,8 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
187187
let [left, right] =
188188
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
189189

190-
let (left, left_len) = this.operand_to_simd(left)?;
191-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
190+
let (left, left_len) = this.project_to_simd(left)?;
191+
let (dest, dest_len) = this.project_to_simd(dest)?;
192192

193193
assert_eq!(dest_len, left_len);
194194

‎src/tools/miri/src/shims/x86/sse2.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
4242
let [left, right] =
4343
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
4444

45-
let (left, left_len) = this.operand_to_simd(left)?;
46-
let (right, right_len) = this.operand_to_simd(right)?;
47-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
45+
let (left, left_len) = this.project_to_simd(left)?;
46+
let (right, right_len) = this.project_to_simd(right)?;
47+
let (dest, dest_len) = this.project_to_simd(dest)?;
4848

4949
assert_eq!(left_len, right_len);
5050
assert_eq!(dest_len.strict_mul(2), left_len);
@@ -81,9 +81,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8181
let [left, right] =
8282
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
8383

84-
let (left, left_len) = this.operand_to_simd(left)?;
85-
let (right, right_len) = this.operand_to_simd(right)?;
86-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
84+
let (left, left_len) = this.project_to_simd(left)?;
85+
let (right, right_len) = this.project_to_simd(right)?;
86+
let (dest, dest_len) = this.project_to_simd(dest)?;
8787

8888
// left and right are u8x16, dest is u64x2
8989
assert_eq!(left_len, right_len);
@@ -270,8 +270,8 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
270270
let [left, right] =
271271
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
272272

273-
let (left, left_len) = this.operand_to_simd(left)?;
274-
let (right, right_len) = this.operand_to_simd(right)?;
273+
let (left, left_len) = this.project_to_simd(left)?;
274+
let (right, right_len) = this.project_to_simd(right)?;
275275

276276
assert_eq!(left_len, right_len);
277277

@@ -297,7 +297,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
297297
// Converts the first component of `op` from f64 to i32/i64.
298298
"cvtsd2si" | "cvttsd2si" | "cvtsd2si64" | "cvttsd2si64" => {
299299
let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
300-
let (op, _) = this.operand_to_simd(op)?;
300+
let (op, _) = this.project_to_simd(op)?;
301301

302302
let op = this.read_immediate(&this.project_index(&op, 0)?)?;
303303

@@ -325,9 +325,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
325325
let [left, right] =
326326
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
327327

328-
let (left, left_len) = this.operand_to_simd(left)?;
329-
let (right, _) = this.operand_to_simd(right)?;
330-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
328+
let (left, left_len) = this.project_to_simd(left)?;
329+
let (right, _) = this.project_to_simd(right)?;
330+
let (dest, dest_len) = this.project_to_simd(dest)?;
331331

332332
assert_eq!(dest_len, left_len);
333333

‎src/tools/miri/src/shims/x86/sse41.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2929
let [left, right, imm] =
3030
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
3131

32-
let (left, left_len) = this.operand_to_simd(left)?;
33-
let (right, right_len) = this.operand_to_simd(right)?;
34-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
32+
let (left, left_len) = this.project_to_simd(left)?;
33+
let (right, right_len) = this.project_to_simd(right)?;
34+
let (dest, dest_len) = this.project_to_simd(dest)?;
3535

3636
assert_eq!(dest_len, left_len);
3737
assert_eq!(dest_len, right_len);
@@ -118,8 +118,8 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
118118
"phminposuw" => {
119119
let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
120120

121-
let (op, op_len) = this.operand_to_simd(op)?;
122-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
121+
let (op, op_len) = this.project_to_simd(op)?;
122+
let (dest, dest_len) = this.project_to_simd(dest)?;
123123

124124
// Find minimum
125125
let mut min_value = u16::MAX;

‎src/tools/miri/src/shims/x86/ssse3.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3434
let [left, right] =
3535
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
3636

37-
let (left, left_len) = this.operand_to_simd(left)?;
38-
let (right, right_len) = this.operand_to_simd(right)?;
39-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
37+
let (left, left_len) = this.project_to_simd(left)?;
38+
let (right, right_len) = this.project_to_simd(right)?;
39+
let (dest, dest_len) = this.project_to_simd(dest)?;
4040

4141
assert_eq!(dest_len, left_len);
4242
assert_eq!(dest_len, right_len);
@@ -84,9 +84,9 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8484
let [left, right] =
8585
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
8686

87-
let (left, left_len) = this.operand_to_simd(left)?;
88-
let (right, right_len) = this.operand_to_simd(right)?;
89-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
87+
let (left, left_len) = this.project_to_simd(left)?;
88+
let (right, right_len) = this.project_to_simd(right)?;
89+
let (dest, dest_len) = this.project_to_simd(dest)?;
9090

9191
assert_eq!(left_len, right_len);
9292
assert_eq!(dest_len.strict_mul(2), left_len);

0 commit comments

Comments
 (0)
Please sign in to comment.