@@ -218,19 +218,34 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
218
218
} ;
219
219
self . write_scalar ( val, dest) ?;
220
220
}
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 => {
222
228
let l = self . read_immediate ( args[ 0 ] ) ?;
223
229
let r = self . read_immediate ( args[ 1 ] ) ?;
224
230
let bin_op = match intrinsic_name {
225
231
sym:: unchecked_shl => BinOp :: Shl ,
226
232
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 ,
227
238
_ => bug ! ( "Already checked for int ops" ) ,
228
239
} ;
229
240
let ( val, overflowed, _ty) = self . overflowing_binary_op ( bin_op, l, r) ?;
230
241
if overflowed {
231
242
let layout = self . layout_of ( substs. type_at ( 0 ) ) ?;
232
243
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
+ }
234
249
}
235
250
self . write_scalar ( val, dest) ?;
236
251
}
0 commit comments