@@ -312,7 +312,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
312
312
Rvalue :: Use ( _) |
313
313
Rvalue :: Len ( _) |
314
314
Rvalue :: Cast ( ..) |
315
- Rvalue :: NullaryOp ( ..) => {
315
+ Rvalue :: NullaryOp ( ..) |
316
+ Rvalue :: CheckedBinaryOp ( ..) => {
316
317
self . use_ecx ( source_info, |this| {
317
318
this. ecx . eval_rvalue_into_place ( rvalue, place) ?;
318
319
this. ecx . eval_place_to_op ( place, Some ( place_layout) )
@@ -348,7 +349,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
348
349
this. ecx . eval_place_to_op ( place, Some ( place_layout) )
349
350
} )
350
351
}
351
- Rvalue :: CheckedBinaryOp ( op, ref left, ref right) |
352
352
Rvalue :: BinaryOp ( op, ref left, ref right) => {
353
353
trace ! ( "rvalue binop {:?} for {:?} and {:?}" , op, left, right) ;
354
354
let right = self . eval_operand ( right, source_info) ?;
@@ -403,23 +403,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
403
403
let ( val, overflow, _ty) = self . use_ecx ( source_info, |this| {
404
404
this. ecx . overflowing_binary_op ( op, l, r)
405
405
} ) ?;
406
- let val = if let Rvalue :: CheckedBinaryOp ( ..) = * rvalue {
407
- Immediate :: ScalarPair (
408
- val. into ( ) ,
409
- Scalar :: from_bool ( overflow) . into ( ) ,
410
- )
411
- } else {
412
- // We check overflow in debug mode already
413
- // so should only check in release mode.
414
- if !self . tcx . sess . overflow_checks ( ) && overflow {
415
- let err = err_panic ! ( Overflow ( op) ) . into ( ) ;
416
- let _: Option < ( ) > = self . use_ecx ( source_info, |_| Err ( err) ) ;
417
- return None ;
418
- }
419
- Immediate :: Scalar ( val. into ( ) )
420
- } ;
406
+ // We check overflow in debug mode already
407
+ // so should only check in release mode.
408
+ if !self . tcx . sess . overflow_checks ( ) && overflow {
409
+ let err = err_panic ! ( Overflow ( op) ) . into ( ) ;
410
+ let _: Option < ( ) > = self . use_ecx ( source_info, |_| Err ( err) ) ;
411
+ return None ;
412
+ }
421
413
let res = ImmTy {
422
- imm : val,
414
+ imm : Immediate :: Scalar ( val. into ( ) ) ,
423
415
layout : place_layout,
424
416
} ;
425
417
Some ( res. into ( ) )
0 commit comments