Skip to content

Commit 1ac2283

Browse files
committed
Use intrinsics for {f16,f32,f64,f128}::{minimum,maximum} operations
1 parent fcb4ef5 commit 1ac2283

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/intrinsic/mod.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,44 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
7474
sym::fabsf64 => "fabs",
7575
sym::minnumf32 => "fminf",
7676
sym::minnumf64 => "fmin",
77+
sym::minimumf32 => "fminimumf",
78+
sym::minimumf64 => "fminimum",
79+
sym::minimumf128 => {
80+
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
81+
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fminimumf128.html
82+
let f128_type = cx.type_f128();
83+
return Some(cx.context.new_function(
84+
None,
85+
FunctionType::Extern,
86+
f128_type,
87+
&[
88+
cx.context.new_parameter(None, f128_type, "a"),
89+
cx.context.new_parameter(None, f128_type, "b"),
90+
],
91+
"fminimumf128",
92+
false,
93+
));
94+
}
7795
sym::maxnumf32 => "fmaxf",
7896
sym::maxnumf64 => "fmax",
97+
sym::maximumf32 => "fmaximumf",
98+
sym::maximumf64 => "fmaximum",
99+
sym::maximumf128 => {
100+
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
101+
// https://docs.rs/compiler_builtins/latest/compiler_builtins/math/full_availability/fn.fmaximumf128.html
102+
let f128_type = cx.type_f128();
103+
return Some(cx.context.new_function(
104+
None,
105+
FunctionType::Extern,
106+
f128_type,
107+
&[
108+
cx.context.new_parameter(None, f128_type, "a"),
109+
cx.context.new_parameter(None, f128_type, "b"),
110+
],
111+
"fmaximumf128",
112+
false,
113+
));
114+
}
79115
sym::copysignf32 => "copysignf",
80116
sym::copysignf64 => "copysign",
81117
sym::copysignf128 => "copysignl",

0 commit comments

Comments
 (0)