diff options
| author | Ralf Jung <post@ralfj.de> | 2025-04-29 11:03:30 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-04-29 11:05:06 +0200 |
| commit | 2393e447eba2edf86c90812a78b78b37a5374f6b (patch) | |
| tree | 18d9da03c115ccd67ce46e82ec135f668b709b1c /compiler/rustc_const_eval/src | |
| parent | 1b8ab72680f36e783af84c1a3c4f8508572bd9f9 (diff) | |
| download | rust-2393e447eba2edf86c90812a78b78b37a5374f6b.tar.gz rust-2393e447eba2edf86c90812a78b78b37a5374f6b.zip | |
miri: algebraic intrinsics: bring back float non-determinism
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/machine.rs | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 40c63f2b250..63043de9739 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -178,8 +178,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let res = self.binary_op(op, &a, &b)?; // `binary_op` already called `generate_nan` if needed. - - // FIXME: Miri should add some non-determinism to the result here to catch any dependences on exact computations. This has previously been done, but the behaviour was removed as part of constification. + let res = M::apply_float_nondet(self, res)?; self.write_immediate(*res, dest)?; } diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index e5026eff21f..a1386b4e1be 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -276,6 +276,14 @@ pub trait Machine<'tcx>: Sized { F2::NAN } + /// Apply non-determinism to float operations that do not return a precise result. + fn apply_float_nondet( + _ecx: &mut InterpCx<'tcx, Self>, + val: ImmTy<'tcx, Self::Provenance>, + ) -> InterpResult<'tcx, ImmTy<'tcx, Self::Provenance>> { + interp_ok(val) + } + /// Determines the result of `min`/`max` on floats when the arguments are equal. fn equal_float_min_max<F: Float>(_ecx: &InterpCx<'tcx, Self>, a: F, _b: F) -> F { // By default, we pick the left argument. |
