@@ -60,7 +60,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6060 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
6161 let dest = this. project_index ( & dest, i) ?;
6262 let val = match which {
63- Op :: MirOp ( mir_op) => this. unary_op ( mir_op, & op) ?. to_scalar ( ) ,
63+ Op :: MirOp ( mir_op) => this. wrapping_unary_op ( mir_op, & op) ?. to_scalar ( ) ,
6464 Op :: Abs => {
6565 // Works for f32 and f64.
6666 let ty:: Float ( float_ty) = op. layout . ty . kind ( ) else {
@@ -177,7 +177,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
177177 let dest = this. project_index ( & dest, i) ?;
178178 let val = match which {
179179 Op :: MirOp ( mir_op) => {
180- let ( val, overflowed, ty ) = this. overflowing_binary_op ( mir_op, & left, & right) ?;
180+ let ( val, overflowed) = this. overflowing_binary_op ( mir_op, & left, & right) ?;
181181 if matches ! ( mir_op, BinOp :: Shl | BinOp :: Shr ) {
182182 // Shifts have extra UB as SIMD operations that the MIR binop does not have.
183183 // See <https://github.com/rust-lang/rust/issues/91237>.
@@ -188,13 +188,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
188188 }
189189 if matches ! ( mir_op, BinOp :: Eq | BinOp :: Ne | BinOp :: Lt | BinOp :: Le | BinOp :: Gt | BinOp :: Ge ) {
190190 // Special handling for boolean-returning operations
191- assert_eq ! ( ty, this. tcx. types. bool ) ;
192- let val = val. to_bool ( ) . unwrap ( ) ;
191+ assert_eq ! ( val . layout . ty, this. tcx. types. bool ) ;
192+ let val = val. to_scalar ( ) . to_bool ( ) . unwrap ( ) ;
193193 bool_to_simd_element ( val, dest. layout . size )
194194 } else {
195- assert_ne ! ( ty, this. tcx. types. bool ) ;
196- assert_eq ! ( ty, dest. layout. ty) ;
197- val
195+ assert_ne ! ( val . layout . ty, this. tcx. types. bool ) ;
196+ assert_eq ! ( val . layout . ty, dest. layout. ty) ;
197+ val. to_scalar ( )
198198 }
199199 }
200200 Op :: SaturatingOp ( mir_op) => {
@@ -304,18 +304,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
304304 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
305305 res = match which {
306306 Op :: MirOp ( mir_op) => {
307- this. binary_op ( mir_op, & res, & op) ?
307+ this. wrapping_binary_op ( mir_op, & res, & op) ?
308308 }
309309 Op :: MirOpBool ( mir_op) => {
310310 let op = imm_from_bool ( simd_element_to_bool ( op) ?) ;
311- this. binary_op ( mir_op, & res, & op) ?
311+ this. wrapping_binary_op ( mir_op, & res, & op) ?
312312 }
313313 Op :: Max => {
314314 if matches ! ( res. layout. ty. kind( ) , ty:: Float ( _) ) {
315315 ImmTy :: from_scalar ( fmax_op ( & res, & op) ?, res. layout )
316316 } else {
317317 // Just boring integers, so NaNs to worry about
318- if this. binary_op ( BinOp :: Ge , & res, & op) ?. to_scalar ( ) . to_bool ( ) ? {
318+ if this. wrapping_binary_op ( BinOp :: Ge , & res, & op) ?. to_scalar ( ) . to_bool ( ) ? {
319319 res
320320 } else {
321321 op
@@ -327,7 +327,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
327327 ImmTy :: from_scalar ( fmin_op ( & res, & op) ?, res. layout )
328328 } else {
329329 // Just boring integers, so NaNs to worry about
330- if this. binary_op ( BinOp :: Le , & res, & op) ?. to_scalar ( ) . to_bool ( ) ? {
330+ if this. wrapping_binary_op ( BinOp :: Le , & res, & op) ?. to_scalar ( ) . to_bool ( ) ? {
331331 res
332332 } else {
333333 op
@@ -356,7 +356,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
356356 let mut res = init;
357357 for i in 0 ..op_len {
358358 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
359- res = this. binary_op ( mir_op, & res, & op) ?;
359+ res = this. wrapping_binary_op ( mir_op, & res, & op) ?;
360360 }
361361 this. write_immediate ( * res, dest) ?;
362362 }
@@ -487,7 +487,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
487487 to_ty = dest. layout. ty,
488488 ) ,
489489 } ;
490- this. write_immediate ( val, & dest) ?;
490+ this. write_immediate ( * val, & dest) ?;
491491 }
492492 }
493493 "shuffle" => {
0 commit comments