Skip to content

Commit e60d62b

Browse files
committed
Make some float methods unstable const fn
Some float methods are now `const fn` under the `const_float_methods` feature gate. In order to support `min`, `max`, `abs` and `copysign`, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval.
1 parent 84c991e commit e60d62b

File tree

1 file changed

+0
-39
lines changed

1 file changed

+0
-39
lines changed

src/intrinsics/mod.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
145145
this.write_scalar(Scalar::from_bool(branch), dest)?;
146146
}
147147

148-
// Floating-point operations
149-
"fabsf32" => {
150-
let [f] = check_arg_count(args)?;
151-
let f = this.read_scalar(f)?.to_f32()?;
152-
// This is a "bitwise" operation, so there's no NaN non-determinism.
153-
this.write_scalar(Scalar::from_f32(f.abs()), dest)?;
154-
}
155-
"fabsf64" => {
156-
let [f] = check_arg_count(args)?;
157-
let f = this.read_scalar(f)?.to_f64()?;
158-
// This is a "bitwise" operation, so there's no NaN non-determinism.
159-
this.write_scalar(Scalar::from_f64(f.abs()), dest)?;
160-
}
161-
162148
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
163149
let [f] = check_arg_count(args)?;
164150
let f = this.read_scalar(f)?.to_f32()?;
@@ -249,31 +235,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
249235
this.write_scalar(res, dest)?;
250236
}
251237

252-
"minnumf32" | "maxnumf32" | "copysignf32" => {
253-
let [a, b] = check_arg_count(args)?;
254-
let a = this.read_scalar(a)?.to_f32()?;
255-
let b = this.read_scalar(b)?.to_f32()?;
256-
let res = match intrinsic_name {
257-
"minnumf32" => this.adjust_nan(a.min(b), &[a, b]),
258-
"maxnumf32" => this.adjust_nan(a.max(b), &[a, b]),
259-
"copysignf32" => a.copy_sign(b), // bitwise, no NaN adjustments
260-
_ => bug!(),
261-
};
262-
this.write_scalar(Scalar::from_f32(res), dest)?;
263-
}
264-
"minnumf64" | "maxnumf64" | "copysignf64" => {
265-
let [a, b] = check_arg_count(args)?;
266-
let a = this.read_scalar(a)?.to_f64()?;
267-
let b = this.read_scalar(b)?.to_f64()?;
268-
let res = match intrinsic_name {
269-
"minnumf64" => this.adjust_nan(a.min(b), &[a, b]),
270-
"maxnumf64" => this.adjust_nan(a.max(b), &[a, b]),
271-
"copysignf64" => a.copy_sign(b), // bitwise, no NaN adjustments
272-
_ => bug!(),
273-
};
274-
this.write_scalar(Scalar::from_f64(res), dest)?;
275-
}
276-
277238
"fmaf32" => {
278239
let [a, b, c] = check_arg_count(args)?;
279240
let a = this.read_scalar(a)?.to_f32()?;

0 commit comments

Comments
 (0)