@@ -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) ;
@@ -924,6 +926,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
924
926
bx. select ( is_lt, bx. cx ( ) . const_i8 ( Ordering :: Less as i8 ) , ge)
925
927
}
926
928
}
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
+ }
927
934
}
928
935
}
929
936
@@ -1036,7 +1043,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1036
1043
mir:: Rvalue :: Cast ( ..) | // (*)
1037
1044
mir:: Rvalue :: ShallowInitBox ( ..) | // (*)
1038
1045
mir:: Rvalue :: BinaryOp ( ..) |
1039
- mir:: Rvalue :: CheckedBinaryOp ( ..) |
1040
1046
mir:: Rvalue :: UnaryOp ( ..) |
1041
1047
mir:: Rvalue :: Discriminant ( ..) |
1042
1048
mir:: Rvalue :: NullaryOp ( ..) |
0 commit comments