@@ -576,6 +576,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
576
576
}
577
577
}
578
578
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
+ }
579
595
mir:: Rvalue :: BinaryOp ( op, box ( ref lhs, ref rhs) ) => {
580
596
let lhs = self . codegen_operand ( bx, lhs) ;
581
597
let rhs = self . codegen_operand ( bx, rhs) ;
@@ -604,20 +620,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
604
620
layout : bx. cx ( ) . layout_of ( op. ty ( bx. tcx ( ) , lhs. layout . ty , rhs. layout . ty ) ) ,
605
621
}
606
622
}
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
- }
621
623
622
624
mir:: Rvalue :: UnaryOp ( op, ref operand) => {
623
625
let operand = self . codegen_operand ( bx, operand) ;
@@ -928,6 +930,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
928
930
bx. select ( is_lt, bx. cx ( ) . const_i8 ( Ordering :: Less as i8 ) , ge)
929
931
}
930
932
}
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
+ }
931
938
}
932
939
}
933
940
@@ -1040,7 +1047,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1040
1047
mir:: Rvalue :: Cast ( ..) | // (*)
1041
1048
mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
1042
1049
mir:: Rvalue :: BinaryOp ( ..) |
1043
- mir:: Rvalue :: CheckedBinaryOp ( ..) |
1044
1050
mir:: Rvalue :: UnaryOp ( ..) |
1045
1051
mir:: Rvalue :: Discriminant ( ..) |
1046
1052
mir:: Rvalue :: NullaryOp ( ..) |
0 commit comments