@@ -572,6 +572,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
572
572
}
573
573
}
574
574
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
+ }
575
591
mir:: Rvalue :: BinaryOp ( op, box ( ref lhs, ref rhs) ) => {
576
592
let lhs = self . codegen_operand ( bx, lhs) ;
577
593
let rhs = self . codegen_operand ( bx, rhs) ;
@@ -600,20 +616,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
600
616
layout : bx. cx ( ) . layout_of ( op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ) ,
601
617
}
602
618
}
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
- }
617
619
618
620
mir:: Rvalue :: UnaryOp ( op, ref operand) => {
619
621
let operand = self . codegen_operand ( bx, operand) ;
@@ -792,7 +794,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
792
794
debug_assert ! (
793
795
if bx. cx( ) . type_has_metadata( ty) {
794
796
matches!( val, OperandValue :: Pair ( ..) )
795
- } else {
797
+ } else {
796
798
matches!( val, OperandValue :: Immediate ( ..) )
797
799
} ,
798
800
"Address of place was unexpectedly {val:?} for pointee type {ty:?}" ,
@@ -938,6 +940,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
938
940
bx. select ( is_lt, bx. cx ( ) . const_i8 ( Ordering :: Less as i8 ) , ge)
939
941
}
940
942
}
943
+ mir:: BinOp :: AddWithOverflow
944
+ | mir:: BinOp :: SubWithOverflow
945
+ | mir:: BinOp :: MulWithOverflow => {
946
+ bug ! ( "{op:?} needs to return a pair, so call codegen_scalar_checked_binop instead" )
947
+ }
941
948
}
942
949
}
943
950
@@ -1050,7 +1057,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1050
1057
mir:: Rvalue :: Cast ( ..) | // (*)
1051
1058
mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
1052
1059
mir:: Rvalue :: BinaryOp ( ..) |
1053
- mir:: Rvalue :: CheckedBinaryOp ( ..) |
1054
1060
mir:: Rvalue :: UnaryOp ( ..) |
1055
1061
mir:: Rvalue :: Discriminant ( ..) |
1056
1062
mir:: Rvalue :: NullaryOp ( ..) |
0 commit comments