@@ -75,7 +75,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
75
75
assert_eq ! ( dest_len, mask_len) ;
76
76
77
77
let mask_item_size = mask. layout . field ( this, 0 ) . size ;
78
- let high_bit_offset = mask_item_size. bits ( ) . checked_sub ( 1 ) . unwrap ( ) ;
78
+ let high_bit_offset = mask_item_size. bits ( ) . strict_sub ( 1 ) ;
79
79
80
80
let scale = this. read_scalar ( scale) ?. to_i8 ( ) ?;
81
81
if !matches ! ( scale, 1 | 2 | 4 | 8 ) {
@@ -93,8 +93,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
93
93
let offset =
94
94
i64:: try_from ( this. read_scalar ( & offset) ?. to_int ( offset. layout . size ) ?)
95
95
. unwrap ( ) ;
96
- let ptr = slice
97
- . wrapping_signed_offset ( offset. checked_mul ( scale) . unwrap ( ) , & this. tcx ) ;
96
+ let ptr = slice. wrapping_signed_offset ( offset. strict_mul ( scale) , & this. tcx ) ;
98
97
// Unaligned copy, which is what we want.
99
98
this. mem_copy (
100
99
ptr,
@@ -124,22 +123,22 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
124
123
let ( dest, dest_len) = this. mplace_to_simd ( dest) ?;
125
124
126
125
assert_eq ! ( left_len, right_len) ;
127
- assert_eq ! ( dest_len. checked_mul ( 2 ) . unwrap ( ) , left_len) ;
126
+ assert_eq ! ( dest_len. strict_mul ( 2 ) , left_len) ;
128
127
129
128
for i in 0 ..dest_len {
130
- let j1 = i. checked_mul ( 2 ) . unwrap ( ) ;
129
+ let j1 = i. strict_mul ( 2 ) ;
131
130
let left1 = this. read_scalar ( & this. project_index ( & left, j1) ?) ?. to_i16 ( ) ?;
132
131
let right1 = this. read_scalar ( & this. project_index ( & right, j1) ?) ?. to_i16 ( ) ?;
133
132
134
- let j2 = j1. checked_add ( 1 ) . unwrap ( ) ;
133
+ let j2 = j1. strict_add ( 1 ) ;
135
134
let left2 = this. read_scalar ( & this. project_index ( & left, j2) ?) ?. to_i16 ( ) ?;
136
135
let right2 = this. read_scalar ( & this. project_index ( & right, j2) ?) ?. to_i16 ( ) ?;
137
136
138
137
let dest = this. project_index ( & dest, i) ?;
139
138
140
139
// Multiplications are i16*i16->i32, which will not overflow.
141
- let mul1 = i32:: from ( left1) . checked_mul ( right1. into ( ) ) . unwrap ( ) ;
142
- let mul2 = i32:: from ( left2) . checked_mul ( right2. into ( ) ) . unwrap ( ) ;
140
+ let mul1 = i32:: from ( left1) . strict_mul ( right1. into ( ) ) ;
141
+ let mul2 = i32:: from ( left2) . strict_mul ( right2. into ( ) ) ;
143
142
// However, this addition can overflow in the most extreme case
144
143
// (-0x8000)*(-0x8000)+(-0x8000)*(-0x8000) = 0x80000000
145
144
let res = mul1. wrapping_add ( mul2) ;
@@ -161,22 +160,22 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
161
160
let ( dest, dest_len) = this. mplace_to_simd ( dest) ?;
162
161
163
162
assert_eq ! ( left_len, right_len) ;
164
- assert_eq ! ( dest_len. checked_mul ( 2 ) . unwrap ( ) , left_len) ;
163
+ assert_eq ! ( dest_len. strict_mul ( 2 ) , left_len) ;
165
164
166
165
for i in 0 ..dest_len {
167
- let j1 = i. checked_mul ( 2 ) . unwrap ( ) ;
166
+ let j1 = i. strict_mul ( 2 ) ;
168
167
let left1 = this. read_scalar ( & this. project_index ( & left, j1) ?) ?. to_u8 ( ) ?;
169
168
let right1 = this. read_scalar ( & this. project_index ( & right, j1) ?) ?. to_i8 ( ) ?;
170
169
171
- let j2 = j1. checked_add ( 1 ) . unwrap ( ) ;
170
+ let j2 = j1. strict_add ( 1 ) ;
172
171
let left2 = this. read_scalar ( & this. project_index ( & left, j2) ?) ?. to_u8 ( ) ?;
173
172
let right2 = this. read_scalar ( & this. project_index ( & right, j2) ?) ?. to_i8 ( ) ?;
174
173
175
174
let dest = this. project_index ( & dest, i) ?;
176
175
177
176
// Multiplication of a u8 and an i8 into an i16 cannot overflow.
178
- let mul1 = i16:: from ( left1) . checked_mul ( right1. into ( ) ) . unwrap ( ) ;
179
- let mul2 = i16:: from ( left2) . checked_mul ( right2. into ( ) ) . unwrap ( ) ;
177
+ let mul1 = i16:: from ( left1) . strict_mul ( right1. into ( ) ) ;
178
+ let mul2 = i16:: from ( left2) . strict_mul ( right2. into ( ) ) ;
180
179
let res = mul1. saturating_add ( mul2) ;
181
180
182
181
this. write_scalar ( Scalar :: from_i16 ( res) , & dest) ?;
@@ -309,7 +308,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
309
308
310
309
for i in 0 ..2 {
311
310
let dest = this. project_index ( & dest, i) ?;
312
- let src = match ( imm >> i. checked_mul ( 4 ) . unwrap ( ) ) & 0b11 {
311
+ let src = match ( imm >> i. strict_mul ( 4 ) ) & 0b11 {
313
312
0 => this. project_index ( & left, 0 ) ?,
314
313
1 => this. project_index ( & left, 1 ) ?,
315
314
2 => this. project_index ( & right, 0 ) ?,
@@ -336,22 +335,22 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
336
335
let ( dest, dest_len) = this. mplace_to_simd ( dest) ?;
337
336
338
337
assert_eq ! ( left_len, right_len) ;
339
- assert_eq ! ( left_len, dest_len. checked_mul ( 8 ) . unwrap ( ) ) ;
338
+ assert_eq ! ( left_len, dest_len. strict_mul ( 8 ) ) ;
340
339
341
340
for i in 0 ..dest_len {
342
341
let dest = this. project_index ( & dest, i) ?;
343
342
344
343
let mut acc: u16 = 0 ;
345
344
for j in 0 ..8 {
346
- let src_index = i. checked_mul ( 8 ) . unwrap ( ) . checked_add ( j ) . unwrap ( ) ;
345
+ let src_index = i. strict_mul ( 8 ) . strict_add ( j ) ;
347
346
348
347
let left = this. project_index ( & left, src_index) ?;
349
348
let left = this. read_scalar ( & left) ?. to_u8 ( ) ?;
350
349
351
350
let right = this. project_index ( & right, src_index) ?;
352
351
let right = this. read_scalar ( & right) ?. to_u8 ( ) ?;
353
352
354
- acc = acc. checked_add ( left. abs_diff ( right) . into ( ) ) . unwrap ( ) ;
353
+ acc = acc. strict_add ( left. abs_diff ( right) . into ( ) ) ;
355
354
}
356
355
357
356
this. write_scalar ( Scalar :: from_u64 ( acc. into ( ) ) , & dest) ?;
@@ -377,7 +376,7 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
377
376
378
377
let res = if right & 0x80 == 0 {
379
378
// Shuffle each 128-bit (16-byte) block independently.
380
- let j = u64:: from ( right % 16 ) . checked_add ( i & !15 ) . unwrap ( ) ;
379
+ let j = u64:: from ( right % 16 ) . strict_add ( i & !15 ) ;
381
380
this. read_scalar ( & this. project_index ( & left, j) ?) ?
382
381
} else {
383
382
// If the highest bit in `right` is 1, write zero.
0 commit comments