Skip to content

Commit 5030e81

Browse files
committed
rename min/maxnum intrinsics to min/maximum_number and fix their LLVM lowering
1 parent f441cc6 commit 5030e81

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/intrinsics/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12661266
ret.write_cvalue(fx, val);
12671267
}
12681268

1269-
sym::minnumf16 => {
1269+
sym::minimum_number_nsz_f16 => {
12701270
intrinsic_args!(fx, args => (a, b); intrinsic);
12711271
let a = a.load_scalar(fx);
12721272
let b = b.load_scalar(fx);
@@ -1275,7 +1275,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12751275
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f16));
12761276
ret.write_cvalue(fx, val);
12771277
}
1278-
sym::minnumf32 => {
1278+
sym::minimum_number_nsz_f32 => {
12791279
intrinsic_args!(fx, args => (a, b); intrinsic);
12801280
let a = a.load_scalar(fx);
12811281
let b = b.load_scalar(fx);
@@ -1284,7 +1284,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12841284
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32));
12851285
ret.write_cvalue(fx, val);
12861286
}
1287-
sym::minnumf64 => {
1287+
sym::minimum_number_nsz_f64 => {
12881288
intrinsic_args!(fx, args => (a, b); intrinsic);
12891289
let a = a.load_scalar(fx);
12901290
let b = b.load_scalar(fx);
@@ -1293,7 +1293,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
12931293
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64));
12941294
ret.write_cvalue(fx, val);
12951295
}
1296-
sym::minnumf128 => {
1296+
sym::minimum_number_nsz_f128 => {
12971297
intrinsic_args!(fx, args => (a, b); intrinsic);
12981298
let a = a.load_scalar(fx);
12991299
let b = b.load_scalar(fx);
@@ -1302,7 +1302,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
13021302
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f128));
13031303
ret.write_cvalue(fx, val);
13041304
}
1305-
sym::maxnumf16 => {
1305+
sym::maximum_number_nsz_f16 => {
13061306
intrinsic_args!(fx, args => (a, b); intrinsic);
13071307
let a = a.load_scalar(fx);
13081308
let b = b.load_scalar(fx);
@@ -1311,7 +1311,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
13111311
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f16));
13121312
ret.write_cvalue(fx, val);
13131313
}
1314-
sym::maxnumf32 => {
1314+
sym::maximum_number_nsz_f32 => {
13151315
intrinsic_args!(fx, args => (a, b); intrinsic);
13161316
let a = a.load_scalar(fx);
13171317
let b = b.load_scalar(fx);
@@ -1320,7 +1320,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
13201320
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f32));
13211321
ret.write_cvalue(fx, val);
13221322
}
1323-
sym::maxnumf64 => {
1323+
sym::maximum_number_nsz_f64 => {
13241324
intrinsic_args!(fx, args => (a, b); intrinsic);
13251325
let a = a.load_scalar(fx);
13261326
let b = b.load_scalar(fx);
@@ -1329,7 +1329,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
13291329
let val = CValue::by_val(val, fx.layout_of(fx.tcx.types.f64));
13301330
ret.write_cvalue(fx, val);
13311331
}
1332-
sym::maxnumf128 => {
1332+
sym::maximum_number_nsz_f128 => {
13331333
intrinsic_args!(fx, args => (a, b); intrinsic);
13341334
let a = a.load_scalar(fx);
13351335
let b = b.load_scalar(fx);

src/num.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ fn codegen_ptr_binop<'tcx>(
498498
}
499499
}
500500

501-
// In Rust floating point min and max don't propagate NaN. In Cranelift they do however.
502-
// For this reason it is necessary to use `a.is_nan() ? b : (a >= b ? b : a)` for `minnumf*`
503-
// and `a.is_nan() ? b : (a <= b ? b : a)` for `maxnumf*`. NaN checks are done by comparing
504-
// a float against itself. Only in case of NaN is it not equal to itself.
501+
// In Rust floating point min and max don't propagate NaN (not even SNaN). In Cranelift they do
502+
// however. For this reason it is necessary to use `a.is_nan() ? b : (a >= b ? b : a)` for
503+
// `minnumf*` and `a.is_nan() ? b : (a <= b ? b : a)` for `maxnumf*`. NaN checks are done by
504+
// comparing a float against itself. Only in case of NaN is it not equal to itself.
505505
pub(crate) fn codegen_float_min(fx: &mut FunctionCx<'_, '_, '_>, a: Value, b: Value) -> Value {
506506
// FIXME(bytecodealliance/wasmtime#8312): Replace with Cranelift `fcmp` once
507507
// `f16`/`f128` backend lowerings have been added to Cranelift.

0 commit comments

Comments
 (0)