Skip to content

Commit 7a0baab

Browse files
author
The Miri Cronjob Bot
committed
Merge ref '864339abf952' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 864339abf952f07098dd82610256338520167d4a Filtered ref: f6ad94b Upstream diff: rust-lang/rust@3ff30e7...864339a This merge was created using https://github.com/rust-lang/josh-sync.
2 parents a054c58 + f6ad94b commit 7a0baab

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/math.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,19 @@ where
272272
("pow", [base, exp]) if *base == one => {
273273
let rng = this.machine.rng.get_mut();
274274
// SNaN exponents get special treatment: they might return 1, or a NaN.
275+
// This is non-deterministic because LLVM can treat SNaN as QNaN, and because
276+
// implementation behavior differs between glibc and musl.
275277
let return_nan = exp.is_signaling() && this.machine.float_nondet && rng.random();
276-
// Handle both the musl and glibc cases non-deterministically.
277278
if return_nan { this.generate_nan(args) } else { one }
278279
}
279280

280281
// x^(±0) = 1 for any x, even a NaN
281282
("pow", [base, exp]) if exp.is_zero() => {
282283
let rng = this.machine.rng.get_mut();
283284
// SNaN bases get special treatment: they might return 1, or a NaN.
285+
// This is non-deterministic because LLVM can treat SNaN as QNaN, and because
286+
// implementation behavior differs between glibc and musl.
284287
let return_nan = base.is_signaling() && this.machine.float_nondet && rng.random();
285-
// Handle both the musl and glibc cases non-deterministically.
286288
if return_nan { this.generate_nan(args) } else { one }
287289
}
288290

@@ -306,10 +308,9 @@ where
306308
0 => {
307309
let one = IeeeFloat::<S>::one();
308310
let rng = ecx.machine.rng.get_mut();
309-
let return_nan = ecx.machine.float_nondet && rng.random() && base.is_signaling();
310-
// For SNaN treatment, we are consistent with `powf`above.
311-
// (We wouldn't have two, unlike powf all implementations seem to agree for powi,
312-
// but for now we are maximally conservative.)
311+
// SNaN bases get special treatment: they might return 1, or a NaN.
312+
// This is non-deterministic because LLVM can treat SNaN as QNaN.
313+
let return_nan = base.is_signaling() && ecx.machine.float_nondet && rng.random();
313314
Some(if return_nan { ecx.generate_nan(&[base]) } else { one })
314315
}
315316

0 commit comments

Comments
 (0)