@@ -347,7 +347,12 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
347
347
}
348
348
TerminatorKind :: Assert { cond, expected, msg, target, cleanup : _ } => {
349
349
if !fx. tcx . sess . overflow_checks ( ) {
350
- if let mir:: AssertKind :: OverflowNeg ( _) = * msg {
350
+ let overflow_not_to_check = match msg {
351
+ AssertKind :: OverflowNeg ( ..) => true ,
352
+ AssertKind :: Overflow ( op, ..) => op. is_checkable ( ) ,
353
+ _ => false ,
354
+ } ;
355
+ if overflow_not_to_check {
351
356
let target = fx. get_block ( * target) ;
352
357
fx. bcx . ins ( ) . jump ( target, & [ ] ) ;
353
358
continue ;
@@ -567,15 +572,7 @@ fn codegen_stmt<'tcx>(
567
572
let lhs = codegen_operand ( fx, & lhs_rhs. 0 ) ;
568
573
let rhs = codegen_operand ( fx, & lhs_rhs. 1 ) ;
569
574
570
- let res = if !fx. tcx . sess . overflow_checks ( ) {
571
- let val =
572
- crate :: num:: codegen_int_binop ( fx, bin_op, lhs, rhs) . load_scalar ( fx) ;
573
- let is_overflow = fx. bcx . ins ( ) . iconst ( types:: I8 , 0 ) ;
574
- CValue :: by_val_pair ( val, is_overflow, lval. layout ( ) )
575
- } else {
576
- crate :: num:: codegen_checked_int_binop ( fx, bin_op, lhs, rhs)
577
- } ;
578
-
575
+ let res = crate :: num:: codegen_checked_int_binop ( fx, bin_op, lhs, rhs) ;
579
576
lval. write_cvalue ( fx, res) ;
580
577
}
581
578
Rvalue :: UnaryOp ( un_op, ref operand) => {
0 commit comments