@@ -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,16 @@ 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) =
83+ this. binary_op ( mir:: BinOp :: SubWithOverflow , & a, & b) ?. to_pair ( this) ;
84+ let ( sub, overflow2) = this
85+ . binary_op (
86+ mir:: BinOp :: SubWithOverflow ,
87+ & sub,
88+ & ImmTy :: from_uint ( b_in, a. layout ) ,
89+ ) ?
90+ . to_pair ( this) ;
91+ let b_out = overflow1. to_scalar ( ) . to_bool ( ) ? | overflow2. to_scalar ( ) . to_bool ( ) ?;
8692
8793 this. write_scalar ( Scalar :: from_u8 ( b_out. into ( ) ) , & this. project_field ( dest, 0 ) ?) ?;
8894 this. write_immediate ( * sub, & this. project_field ( dest, 1 ) ?) ?;
@@ -245,7 +251,7 @@ fn bin_op_float<'tcx, F: rustc_apfloat::Float>(
245251) -> InterpResult < ' tcx , Scalar < Provenance > > {
246252 match which {
247253 FloatBinOp :: Arith ( which) => {
248- let res = this. wrapping_binary_op ( which, left, right) ?;
254+ let res = this. binary_op ( which, left, right) ?;
249255 Ok ( res. to_scalar ( ) )
250256 }
251257 FloatBinOp :: Cmp { gt, lt, eq, unord } => {
@@ -744,12 +750,9 @@ fn int_abs<'tcx>(
744750 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
745751 let dest = this. project_index ( & dest, i) ?;
746752
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- } ;
753+ let lt_zero = this. binary_op ( mir:: BinOp :: Lt , & op, & zero) ?;
754+ let res =
755+ if lt_zero. to_scalar ( ) . to_bool ( ) ? { this. unary_op ( mir:: UnOp :: Neg , & op) ? } else { op } ;
753756
754757 this. write_immediate ( * res, & dest) ?;
755758 }
@@ -832,7 +835,7 @@ fn horizontal_bin_op<'tcx>(
832835 let res = if saturating {
833836 Immediate :: from ( this. saturating_arith ( which, & lhs, & rhs) ?)
834837 } else {
835- * this. wrapping_binary_op ( which, & lhs, & rhs) ?
838+ * this. binary_op ( which, & lhs, & rhs) ?
836839 } ;
837840
838841 this. write_immediate ( res, & this. project_index ( & dest, j) ?) ?;
@@ -884,8 +887,8 @@ fn conditional_dot_product<'tcx>(
884887 let left = this. read_immediate ( & this. project_index ( & left, j) ?) ?;
885888 let right = this. read_immediate ( & this. project_index ( & right, j) ?) ?;
886889
887- let mul = this. wrapping_binary_op ( mir:: BinOp :: Mul , & left, & right) ?;
888- sum = this. wrapping_binary_op ( mir:: BinOp :: Add , & sum, & mul) ?;
890+ let mul = this. binary_op ( mir:: BinOp :: Mul , & left, & right) ?;
891+ sum = this. binary_op ( mir:: BinOp :: Add , & sum, & mul) ?;
889892 }
890893 }
891894
@@ -1276,11 +1279,8 @@ fn psign<'tcx>(
12761279 let left = this. read_immediate ( & this. project_index ( & left, i) ?) ?;
12771280 let right = this. read_scalar ( & this. project_index ( & right, i) ?) ?. to_int ( dest. layout . size ) ?;
12781281
1279- let res = this. wrapping_binary_op (
1280- mir:: BinOp :: Mul ,
1281- & left,
1282- & ImmTy :: from_int ( right. signum ( ) , dest. layout ) ,
1283- ) ?;
1282+ let res =
1283+ this. binary_op ( mir:: BinOp :: Mul , & left, & ImmTy :: from_int ( right. signum ( ) , dest. layout ) ) ?;
12841284
12851285 this. write_immediate ( * res, & dest) ?;
12861286 }
0 commit comments