@@ -334,15 +334,20 @@ fn trans_stmt<'a, 'tcx: 'a>(
334
334
let lhs = trans_operand ( fx, lhs) ;
335
335
let rhs = trans_operand ( fx, rhs) ;
336
336
337
- let res = match ty. sty {
338
- ty:: Uint ( _) => {
339
- trans_checked_int_binop ( fx, * bin_op, lhs, rhs, lval. layout ( ) . ty , false )
340
- }
341
- ty:: Int ( _) => {
342
- trans_checked_int_binop ( fx, * bin_op, lhs, rhs, lval. layout ( ) . ty , true )
343
- }
337
+ let signed = match ty. sty {
338
+ ty:: Uint ( _) => false ,
339
+ ty:: Int ( _) => true ,
344
340
_ => unimplemented ! ( "checked binop {:?} for {:?}" , bin_op, ty) ,
345
341
} ;
342
+
343
+ let res = if !fx. tcx . sess . overflow_checks ( ) {
344
+ let val = trans_int_binop ( fx, * bin_op, lhs, rhs, lhs. layout ( ) . ty , signed) . load_scalar ( fx) ;
345
+ let is_overflow = fx. bcx . ins ( ) . iconst ( types:: I8 , 0 ) ;
346
+ CValue :: by_val_pair ( val, is_overflow, lval. layout ( ) )
347
+ } else {
348
+ trans_checked_int_binop ( fx, * bin_op, lhs, rhs, lval. layout ( ) . ty , signed)
349
+ } ;
350
+
346
351
lval. write_cvalue ( fx, res) ;
347
352
}
348
353
Rvalue :: UnaryOp ( un_op, operand) => {
@@ -843,12 +848,6 @@ pub fn trans_checked_int_binop<'a, 'tcx: 'a>(
843
848
out_ty : Ty < ' tcx > ,
844
849
signed : bool ,
845
850
) -> CValue < ' tcx > {
846
- if !fx. tcx . sess . overflow_checks ( ) {
847
- let val = trans_int_binop ( fx, bin_op, in_lhs, in_rhs, in_lhs. layout ( ) . ty , signed) . load_scalar ( fx) ;
848
- let is_overflow = fx. bcx . ins ( ) . iconst ( types:: I8 , 0 ) ;
849
- return CValue :: by_val_pair ( val, is_overflow, fx. layout_of ( out_ty) ) ;
850
- }
851
-
852
851
if bin_op != BinOp :: Shl && bin_op != BinOp :: Shr {
853
852
assert_eq ! (
854
853
in_lhs. layout( ) . ty,
0 commit comments