@@ -312,7 +312,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
312312 Rvalue :: Use ( _) |
313313 Rvalue :: Len ( _) |
314314 Rvalue :: Cast ( ..) |
315- Rvalue :: NullaryOp ( ..) => {
315+ Rvalue :: NullaryOp ( ..) |
316+ Rvalue :: CheckedBinaryOp ( ..) => {
316317 self . use_ecx ( source_info, |this| {
317318 this. ecx . eval_rvalue_into_place ( rvalue, place) ?;
318319 this. ecx . eval_place_to_op ( place, Some ( place_layout) )
@@ -348,7 +349,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
348349 this. ecx . eval_place_to_op ( place, Some ( place_layout) )
349350 } )
350351 }
351- Rvalue :: CheckedBinaryOp ( op, ref left, ref right) |
352352 Rvalue :: BinaryOp ( op, ref left, ref right) => {
353353 trace ! ( "rvalue binop {:?} for {:?} and {:?}" , op, left, right) ;
354354 let right = self . eval_operand ( right, source_info) ?;
@@ -403,23 +403,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
403403 let ( val, overflow, _ty) = self . use_ecx ( source_info, |this| {
404404 this. ecx . overflowing_binary_op ( op, l, r)
405405 } ) ?;
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+ }
421413 let res = ImmTy {
422- imm : val,
414+ imm : Immediate :: Scalar ( val. into ( ) ) ,
423415 layout : place_layout,
424416 } ;
425417 Some ( res. into ( ) )
0 commit comments