@@ -50,13 +50,16 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
5050 let a = this. read_immediate ( a) ?;
5151 let b = this. read_immediate ( b) ?;
5252
53- let ( sum, overflow1) = this. overflowing_binary_op ( mir:: BinOp :: Add , & a, & b) ?;
54- let ( sum, overflow2) = this. overflowing_binary_op (
55- mir:: BinOp :: Add ,
56- & sum,
57- & ImmTy :: from_uint ( c_in, a. layout ) ,
58- ) ?;
59- let c_out = overflow1 | overflow2;
53+ let ( sum, overflow1) =
54+ this. binary_op ( mir:: BinOp :: AddWithOverflow , & a, & b) ?. to_pair ( this) ;
55+ let ( sum, overflow2) = this
56+ . binary_op (
57+ mir:: BinOp :: AddWithOverflow ,
58+ & sum,
59+ & ImmTy :: from_uint ( c_in, a. layout ) ,
60+ ) ?
61+ . to_pair ( this) ;
62+ let c_out = overflow1. to_scalar ( ) . to_bool ( ) ? | overflow2. to_scalar ( ) . to_bool ( ) ?;
6063
6164 this. write_scalar ( Scalar :: from_u8 ( c_out. into ( ) ) , & this. project_field ( dest, 0 ) ?) ?;
6265 this. write_immediate ( * sum, & this. project_field ( dest, 1 ) ?) ?;
@@ -76,13 +79,11 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
7679 let a = this. read_immediate ( a) ?;
7780 let b = this. read_immediate ( b) ?;
7881
79- let ( sub, overflow1) = this. overflowing_binary_op ( mir:: BinOp :: Sub , & a, & b) ?;
80- let ( sub, overflow2) = this. overflowing_binary_op (
81- mir:: BinOp :: Sub ,
82- & sub,
83- & ImmTy :: from_uint ( b_in, a. layout ) ,
84- ) ?;
85- let b_out = overflow1 | overflow2;
82+ let ( sub, overflow1) = this. binary_op ( mir:: BinOp :: SubWithOverflow , & a, & b) ?. to_pair ( this) ;
83+ let ( sub, overflow2) = this
84+ . binary_op ( mir:: BinOp :: SubWithOverflow , & sub, & ImmTy :: from_uint ( b_in, a. layout ) ) ?
85+ . to_pair ( this) ;
86+ let b_out = overflow1. to_scalar ( ) . to_bool ( ) ? | overflow2. to_scalar ( ) . to_bool ( ) ?;
8687
8788 this. write_scalar ( Scalar :: from_u8 ( b_out. into ( ) ) , & this. project_field ( dest, 0 ) ?) ?;
8889 this. write_immediate ( * sub, & this. project_field ( dest, 1 ) ?) ?;
@@ -245,7 +246,7 @@ fn bin_op_float<'tcx, F: rustc_apfloat::Float>(
245246) -> InterpResult < ' tcx , Scalar < Provenance > > {
246247 match which {
247248 FloatBinOp :: Arith ( which) => {
248- let res = this. wrapping_binary_op ( which, left, right) ?;
249+ let res = this. binary_op ( which, left, right) ?;
249250 Ok ( res. to_scalar ( ) )
250251 }
251252 FloatBinOp :: Cmp { gt, lt, eq, unord } => {
@@ -744,12 +745,9 @@ fn int_abs<'tcx>(
744745 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
745746 let dest = this. project_index ( & dest, i) ?;
746747
747- let lt_zero = this. wrapping_binary_op ( mir:: BinOp :: Lt , & op, & zero) ?;
748- let res = if lt_zero. to_scalar ( ) . to_bool ( ) ? {
749- this. wrapping_unary_op ( mir:: UnOp :: Neg , & op) ?
750- } else {
751- op
752- } ;
748+ let lt_zero = this. binary_op ( mir:: BinOp :: Lt , & op, & zero) ?;
749+ let res =
750+ if lt_zero. to_scalar ( ) . to_bool ( ) ? { this. unary_op ( mir:: UnOp :: Neg , & op) ? } else { op } ;
753751
754752 this. write_immediate ( * res, & dest) ?;
755753 }
@@ -832,7 +830,7 @@ fn horizontal_bin_op<'tcx>(
832830 let res = if saturating {
833831 Immediate :: from ( this. saturating_arith ( which, & lhs, & rhs) ?)
834832 } else {
835- * this. wrapping_binary_op ( which, & lhs, & rhs) ?
833+ * this. binary_op ( which, & lhs, & rhs) ?
836834 } ;
837835
838836 this. write_immediate ( res, & this. project_index ( & dest, j) ?) ?;
@@ -884,8 +882,8 @@ fn conditional_dot_product<'tcx>(
884882 let left = this. read_immediate ( & this. project_index ( & left, j) ?) ?;
885883 let right = this. read_immediate ( & this. project_index ( & right, j) ?) ?;
886884
887- let mul = this. wrapping_binary_op ( mir:: BinOp :: Mul , & left, & right) ?;
888- sum = this. wrapping_binary_op ( mir:: BinOp :: Add , & sum, & mul) ?;
885+ let mul = this. binary_op ( mir:: BinOp :: Mul , & left, & right) ?;
886+ sum = this. binary_op ( mir:: BinOp :: Add , & sum, & mul) ?;
889887 }
890888 }
891889
@@ -1276,11 +1274,8 @@ fn psign<'tcx>(
12761274 let left = this. read_immediate ( & this. project_index ( & left, i) ?) ?;
12771275 let right = this. read_scalar ( & this. project_index ( & right, i) ?) ?. to_int ( dest. layout . size ) ?;
12781276
1279- let res = this. wrapping_binary_op (
1280- mir:: BinOp :: Mul ,
1281- & left,
1282- & ImmTy :: from_int ( right. signum ( ) , dest. layout ) ,
1283- ) ?;
1277+ let res =
1278+ this. binary_op ( mir:: BinOp :: Mul , & left, & ImmTy :: from_int ( right. signum ( ) , dest. layout ) ) ?;
12841279
12851280 this. write_immediate ( * res, & dest) ?;
12861281 }
0 commit comments