@@ -218,19 +218,34 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
218218 } ;
219219 self . write_scalar ( val, dest) ?;
220220 }
221- sym:: unchecked_shl | sym:: unchecked_shr => {
221+ sym:: unchecked_shl
222+ | sym:: unchecked_shr
223+ | sym:: unchecked_add
224+ | sym:: unchecked_sub
225+ | sym:: unchecked_mul
226+ | sym:: unchecked_div
227+ | sym:: unchecked_rem => {
222228 let l = self . read_immediate ( args[ 0 ] ) ?;
223229 let r = self . read_immediate ( args[ 1 ] ) ?;
224230 let bin_op = match intrinsic_name {
225231 sym:: unchecked_shl => BinOp :: Shl ,
226232 sym:: unchecked_shr => BinOp :: Shr ,
233+ sym:: unchecked_add => BinOp :: Add ,
234+ sym:: unchecked_sub => BinOp :: Sub ,
235+ sym:: unchecked_mul => BinOp :: Mul ,
236+ sym:: unchecked_div => BinOp :: Div ,
237+ sym:: unchecked_rem => BinOp :: Rem ,
227238 _ => bug ! ( "Already checked for int ops" ) ,
228239 } ;
229240 let ( val, overflowed, _ty) = self . overflowing_binary_op ( bin_op, l, r) ?;
230241 if overflowed {
231242 let layout = self . layout_of ( substs. type_at ( 0 ) ) ?;
232243 let r_val = self . force_bits ( r. to_scalar ( ) ?, layout. size ) ?;
233- throw_ub_format ! ( "Overflowing shift by {} in `{}`" , r_val, intrinsic_name) ;
244+ if let sym:: unchecked_shl | sym:: unchecked_shr = intrinsic_name {
245+ throw_ub_format ! ( "Overflowing shift by {} in `{}`" , r_val, intrinsic_name) ;
246+ } else {
247+ throw_ub_format ! ( "Overflow executing `{}`" , intrinsic_name) ;
248+ }
234249 }
235250 self . write_scalar ( val, dest) ?;
236251 }
0 commit comments