@@ -576,6 +576,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
576576 }
577577 }
578578
579+ mir:: Rvalue :: BinaryOp ( op_with_overflow, box ( ref lhs, ref rhs) )
580+ if let Some ( op) = op_with_overflow. overflowing_to_wrapping ( ) =>
581+ {
582+ let lhs = self . codegen_operand ( bx, lhs) ;
583+ let rhs = self . codegen_operand ( bx, rhs) ;
584+ let result = self . codegen_scalar_checked_binop (
585+ bx,
586+ op,
587+ lhs. immediate ( ) ,
588+ rhs. immediate ( ) ,
589+ lhs. layout . ty ,
590+ ) ;
591+ let val_ty = op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ;
592+ let operand_ty = Ty :: new_tup ( bx. tcx ( ) , & [ val_ty, bx. tcx ( ) . types . bool ] ) ;
593+ OperandRef { val : result, layout : bx. cx ( ) . layout_of ( operand_ty) }
594+ }
579595 mir:: Rvalue :: BinaryOp ( op, box ( ref lhs, ref rhs) ) => {
580596 let lhs = self . codegen_operand ( bx, lhs) ;
581597 let rhs = self . codegen_operand ( bx, rhs) ;
@@ -604,20 +620,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
604620 layout : bx. cx ( ) . layout_of ( op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ) ,
605621 }
606622 }
607- mir:: Rvalue :: CheckedBinaryOp ( op, box ( ref lhs, ref rhs) ) => {
608- let lhs = self . codegen_operand ( bx, lhs) ;
609- let rhs = self . codegen_operand ( bx, rhs) ;
610- let result = self . codegen_scalar_checked_binop (
611- bx,
612- op,
613- lhs. immediate ( ) ,
614- rhs. immediate ( ) ,
615- lhs. layout . ty ,
616- ) ;
617- let val_ty = op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ;
618- let operand_ty = Ty :: new_tup ( bx. tcx ( ) , & [ val_ty, bx. tcx ( ) . types . bool ] ) ;
619- OperandRef { val : result, layout : bx. cx ( ) . layout_of ( operand_ty) }
620- }
621623
622624 mir:: Rvalue :: UnaryOp ( op, ref operand) => {
623625 let operand = self . codegen_operand ( bx, operand) ;
@@ -928,6 +930,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
928930 bx. select ( is_lt, bx. cx ( ) . const_i8 ( Ordering :: Less as i8 ) , ge)
929931 }
930932 }
933+ mir:: BinOp :: AddWithOverflow
934+ | mir:: BinOp :: SubWithOverflow
935+ | mir:: BinOp :: MulWithOverflow => {
936+ bug ! ( "{op:?} needs to return a pair, so call codegen_scalar_checked_binop instead" )
937+ }
931938 }
932939 }
933940
@@ -1040,7 +1047,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10401047 mir:: Rvalue :: Cast ( ..) | // (*)
10411048 mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
10421049 mir:: Rvalue :: BinaryOp ( ..) |
1043- mir:: Rvalue :: CheckedBinaryOp ( ..) |
10441050 mir:: Rvalue :: UnaryOp ( ..) |
10451051 mir:: Rvalue :: Discriminant ( ..) |
10461052 mir:: Rvalue :: NullaryOp ( ..) |
0 commit comments