@@ -347,7 +347,12 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
347347 }
348348 TerminatorKind :: Assert { cond, expected, msg, target, cleanup : _ } => {
349349 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 {
351356 let target = fx. get_block ( * target) ;
352357 fx. bcx . ins ( ) . jump ( target, & [ ] ) ;
353358 continue ;
@@ -567,15 +572,7 @@ fn codegen_stmt<'tcx>(
567572 let lhs = codegen_operand ( fx, & lhs_rhs. 0 ) ;
568573 let rhs = codegen_operand ( fx, & lhs_rhs. 1 ) ;
569574
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) ;
579576 lval. write_cvalue ( fx, res) ;
580577 }
581578 Rvalue :: UnaryOp ( un_op, ref operand) => {
0 commit comments