Skip to content

Commit 869a2d6

Browse files
author
The Miri Cronjob Bot
committed
Merge ref 'b733736ea2fe' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: b733736ea2feb7798c99cbb9a769bce74be108df Filtered ref: 62d76e7 Upstream diff: rust-lang/rust@f6092f2...b733736 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 8f1061d + 62d76e7 commit 869a2d6

File tree

3 files changed

+15
-41
lines changed

3 files changed

+15
-41
lines changed

src/intrinsics/math.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rand::Rng;
21
use rustc_apfloat::{self, Float, FloatConvert, Round};
32
use rustc_middle::mir;
43
use rustc_middle::ty::{self, FloatTy};
@@ -39,46 +38,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3938
"sqrtf64" => sqrt::<rustc_apfloat::ieee::Double>(this, args, dest)?,
4039
"sqrtf128" => sqrt::<rustc_apfloat::ieee::Quad>(this, args, dest)?,
4140

42-
"fmaf32" => {
43-
let [a, b, c] = check_intrinsic_arg_count(args)?;
44-
let a = this.read_scalar(a)?.to_f32()?;
45-
let b = this.read_scalar(b)?.to_f32()?;
46-
let c = this.read_scalar(c)?.to_f32()?;
47-
let res = a.mul_add(b, c).value;
48-
let res = this.adjust_nan(res, &[a, b, c]);
49-
this.write_scalar(res, dest)?;
50-
}
51-
"fmaf64" => {
52-
let [a, b, c] = check_intrinsic_arg_count(args)?;
53-
let a = this.read_scalar(a)?.to_f64()?;
54-
let b = this.read_scalar(b)?.to_f64()?;
55-
let c = this.read_scalar(c)?.to_f64()?;
56-
let res = a.mul_add(b, c).value;
57-
let res = this.adjust_nan(res, &[a, b, c]);
58-
this.write_scalar(res, dest)?;
59-
}
60-
61-
"fmuladdf32" => {
62-
let [a, b, c] = check_intrinsic_arg_count(args)?;
63-
let a = this.read_scalar(a)?.to_f32()?;
64-
let b = this.read_scalar(b)?.to_f32()?;
65-
let c = this.read_scalar(c)?.to_f32()?;
66-
let fuse: bool = this.machine.float_nondet && this.machine.rng.get_mut().random();
67-
let res = if fuse { a.mul_add(b, c).value } else { ((a * b).value + c).value };
68-
let res = this.adjust_nan(res, &[a, b, c]);
69-
this.write_scalar(res, dest)?;
70-
}
71-
"fmuladdf64" => {
72-
let [a, b, c] = check_intrinsic_arg_count(args)?;
73-
let a = this.read_scalar(a)?.to_f64()?;
74-
let b = this.read_scalar(b)?.to_f64()?;
75-
let c = this.read_scalar(c)?.to_f64()?;
76-
let fuse: bool = this.machine.float_nondet && this.machine.rng.get_mut().random();
77-
let res = if fuse { a.mul_add(b, c).value } else { ((a * b).value + c).value };
78-
let res = this.adjust_nan(res, &[a, b, c]);
79-
this.write_scalar(res, dest)?;
80-
}
81-
8241
#[rustfmt::skip]
8342
| "fadd_fast"
8443
| "fsub_fast"

src/machine.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,11 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
12931293
ecx.equal_float_min_max(a, b)
12941294
}
12951295

1296+
#[inline(always)]
1297+
fn float_fuse_mul_add(ecx: &mut InterpCx<'tcx, Self>) -> bool {
1298+
ecx.machine.float_nondet && ecx.machine.rng.get_mut().random()
1299+
}
1300+
12961301
#[inline(always)]
12971302
fn ub_checks(ecx: &InterpCx<'tcx, Self>) -> InterpResult<'tcx, bool> {
12981303
interp_ok(ecx.tcx.sess.ub_checks())

tests/pass/vec.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ fn miri_issue_2759() {
169169
input.replace_range(0..0, "0");
170170
}
171171

172+
/// This was skirting the edge of UB, let's make sure it remains on the sound side.
173+
/// Context: <https://github.com/rust-lang/rust/pull/141032>.
174+
fn extract_if() {
175+
let mut v = vec![Box::new(0u64), Box::new(1u64)];
176+
for item in v.extract_if(.., |x| **x == 0) {
177+
drop(item);
178+
}
179+
}
180+
172181
fn main() {
173182
assert_eq!(vec_reallocate().len(), 5);
174183

@@ -199,4 +208,5 @@ fn main() {
199208
swap_remove();
200209
reverse();
201210
miri_issue_2759();
211+
extract_if();
202212
}

0 commit comments

Comments
 (0)