@@ -241,16 +241,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
241241 }
242242 "simd_insert" => {
243243 let index = self . read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ? as u64 ;
244- let scalar = self . read_immediate ( args[ 2 ] ) ? ;
244+ let scalar = args[ 2 ] ;
245245 let input = args[ 0 ] ;
246246 let ( len, e_ty) = self . read_vector_ty ( input) ;
247247 assert ! (
248248 index < len,
249- "index `{}` must be in bounds of vector type `{}`: `[0, {})`" ,
249+ "Index `{}` must be in bounds of vector type `{}`: `[0, {})`" ,
250250 index, e_ty, len
251251 ) ;
252252 assert_eq ! (
253- args [ 0 ] . layout, dest. layout,
253+ input . layout, dest. layout,
254254 "Return type `{}` must match vector type `{}`" ,
255255 dest. layout. ty, input. layout. ty
256256 ) ;
@@ -261,34 +261,29 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
261261 ) ;
262262
263263 for i in 0 ..len {
264- let place = self . place_field ( dest, index ) ?;
265- if i == index {
266- self . write_immediate ( * scalar, place ) ? ;
264+ let place = self . place_field ( dest, i ) ?;
265+ let value = if i == index {
266+ scalar
267267 } else {
268- self . write_immediate (
269- * self . read_immediate ( self . operand_field ( input, index) ?) ?,
270- place
271- ) ?;
268+ self . operand_field ( input, i) ?
272269 } ;
270+ self . copy_op ( value, place) ?;
273271 }
274272 }
275273 "simd_extract" => {
276274 let index = self . read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ? as _ ;
277275 let ( len, e_ty) = self . read_vector_ty ( args[ 0 ] ) ;
278276 assert ! (
279277 index < len,
280- "index `{}` must be in bounds of vector type `{}`: `[0, {}) `" ,
278+ "index `{}` is out-of- bounds of vector type `{}` with length `{} `" ,
281279 index, e_ty, len
282280 ) ;
283281 assert_eq ! (
284282 e_ty, dest. layout. ty,
285283 "Return type `{}` must match vector element type `{}`" ,
286284 dest. layout. ty, e_ty
287285 ) ;
288- self . write_immediate (
289- * self . read_immediate ( self . operand_field ( args[ 0 ] , index) ?) ?,
290- dest
291- ) ?;
286+ self . copy_op ( self . operand_field ( args[ 0 ] , index) ?, dest) ?;
292287 }
293288 _ => return Ok ( false ) ,
294289 }
0 commit comments