@@ -50,13 +50,16 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
50
50
let a = this. read_immediate ( a) ?;
51
51
let b = this. read_immediate ( b) ?;
52
52
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 ( ) ?;
60
63
61
64
this. write_scalar ( Scalar :: from_u8 ( c_out. into ( ) ) , & this. project_field ( dest, 0 ) ?) ?;
62
65
this. write_immediate ( * sum, & this. project_field ( dest, 1 ) ?) ?;
@@ -76,13 +79,11 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
76
79
let a = this. read_immediate ( a) ?;
77
80
let b = this. read_immediate ( b) ?;
78
81
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 ( ) ?;
86
87
87
88
this. write_scalar ( Scalar :: from_u8 ( b_out. into ( ) ) , & this. project_field ( dest, 0 ) ?) ?;
88
89
this. write_immediate ( * sub, & this. project_field ( dest, 1 ) ?) ?;
@@ -245,7 +246,7 @@ fn bin_op_float<'tcx, F: rustc_apfloat::Float>(
245
246
) -> InterpResult < ' tcx , Scalar < Provenance > > {
246
247
match which {
247
248
FloatBinOp :: Arith ( which) => {
248
- let res = this. wrapping_binary_op ( which, left, right) ?;
249
+ let res = this. binary_op ( which, left, right) ?;
249
250
Ok ( res. to_scalar ( ) )
250
251
}
251
252
FloatBinOp :: Cmp { gt, lt, eq, unord } => {
@@ -744,12 +745,9 @@ fn int_abs<'tcx>(
744
745
let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
745
746
let dest = this. project_index ( & dest, i) ?;
746
747
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 } ;
753
751
754
752
this. write_immediate ( * res, & dest) ?;
755
753
}
@@ -832,7 +830,7 @@ fn horizontal_bin_op<'tcx>(
832
830
let res = if saturating {
833
831
Immediate :: from ( this. saturating_arith ( which, & lhs, & rhs) ?)
834
832
} else {
835
- * this. wrapping_binary_op ( which, & lhs, & rhs) ?
833
+ * this. binary_op ( which, & lhs, & rhs) ?
836
834
} ;
837
835
838
836
this. write_immediate ( res, & this. project_index ( & dest, j) ?) ?;
@@ -884,8 +882,8 @@ fn conditional_dot_product<'tcx>(
884
882
let left = this. read_immediate ( & this. project_index ( & left, j) ?) ?;
885
883
let right = this. read_immediate ( & this. project_index ( & right, j) ?) ?;
886
884
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) ?;
889
887
}
890
888
}
891
889
@@ -1276,11 +1274,8 @@ fn psign<'tcx>(
1276
1274
let left = this. read_immediate ( & this. project_index ( & left, i) ?) ?;
1277
1275
let right = this. read_scalar ( & this. project_index ( & right, i) ?) ?. to_int ( dest. layout . size ) ?;
1278
1276
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 ) ) ?;
1284
1279
1285
1280
this. write_immediate ( * res, & dest) ?;
1286
1281
}
0 commit comments