@@ -572,6 +572,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
572572 }
573573 }
574574
575+ mir:: Rvalue :: BinaryOp ( op_with_overflow, box ( ref lhs, ref rhs) )
576+ if let Some ( op) = op_with_overflow. overflowing_to_wrapping ( ) =>
577+ {
578+ let lhs = self . codegen_operand ( bx, lhs) ;
579+ let rhs = self . codegen_operand ( bx, rhs) ;
580+ let result = self . codegen_scalar_checked_binop (
581+ bx,
582+ op,
583+ lhs. immediate ( ) ,
584+ rhs. immediate ( ) ,
585+ lhs. layout . ty ,
586+ ) ;
587+ let val_ty = op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ;
588+ let operand_ty = Ty :: new_tup ( bx. tcx ( ) , & [ val_ty, bx. tcx ( ) . types . bool ] ) ;
589+ OperandRef { val : result, layout : bx. cx ( ) . layout_of ( operand_ty) }
590+ }
575591 mir:: Rvalue :: BinaryOp ( op, box ( ref lhs, ref rhs) ) => {
576592 let lhs = self . codegen_operand ( bx, lhs) ;
577593 let rhs = self . codegen_operand ( bx, rhs) ;
@@ -600,20 +616,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
600616 layout : bx. cx ( ) . layout_of ( op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ) ,
601617 }
602618 }
603- mir:: Rvalue :: CheckedBinaryOp ( op, box ( ref lhs, ref rhs) ) => {
604- let lhs = self . codegen_operand ( bx, lhs) ;
605- let rhs = self . codegen_operand ( bx, rhs) ;
606- let result = self . codegen_scalar_checked_binop (
607- bx,
608- op,
609- lhs. immediate ( ) ,
610- rhs. immediate ( ) ,
611- lhs. layout . ty ,
612- ) ;
613- let val_ty = op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ;
614- let operand_ty = Ty :: new_tup ( bx. tcx ( ) , & [ val_ty, bx. tcx ( ) . types . bool ] ) ;
615- OperandRef { val : result, layout : bx. cx ( ) . layout_of ( operand_ty) }
616- }
617619
618620 mir:: Rvalue :: UnaryOp ( op, ref operand) => {
619621 let operand = self . codegen_operand ( bx, operand) ;
@@ -924,6 +926,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
924926 bx. select ( is_lt, bx. cx ( ) . const_i8 ( Ordering :: Less as i8 ) , ge)
925927 }
926928 }
929+ mir:: BinOp :: AddWithOverflow
930+ | mir:: BinOp :: SubWithOverflow
931+ | mir:: BinOp :: MulWithOverflow => {
932+ bug ! ( "{op:?} needs to return a pair, so call codegen_scalar_checked_binop instead" )
933+ }
927934 }
928935 }
929936
@@ -1036,7 +1043,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10361043 mir:: Rvalue :: Cast ( ..) | // (*)
10371044 mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
10381045 mir:: Rvalue :: BinaryOp ( ..) |
1039- mir:: Rvalue :: CheckedBinaryOp ( ..) |
10401046 mir:: Rvalue :: UnaryOp ( ..) |
10411047 mir:: Rvalue :: Discriminant ( ..) |
10421048 mir:: Rvalue :: NullaryOp ( ..) |
0 commit comments