Skip to content

Commit 2acd77e

Browse files
committed
Fix TODO: only call f128 fns if is a f128 fn
1 parent f67c935 commit 2acd77e

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

src/intrinsic/mod.rs

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,7 @@ fn get_simple_function<'gcc, 'tcx>(
120120
fn get_simple_function_f128<'gcc, 'tcx>(
121121
cx: &CodegenCx<'gcc, 'tcx>,
122122
name: Symbol,
123-
) -> Option<Function<'gcc>> {
124-
if !cx.supports_f128_type {
125-
return None;
126-
}
127-
123+
) -> Function<'gcc> {
128124
let f128_type = cx.type_f128();
129125
let func_name = match name {
130126
sym::ceilf128 => "ceilf128",
@@ -134,26 +130,22 @@ fn get_simple_function_f128<'gcc, 'tcx>(
134130
sym::roundf128 => "roundf128",
135131
sym::round_ties_even_f128 => "roundevenf128",
136132
sym::sqrtf128 => "sqrtf128",
137-
_ => return None,
133+
_ => unreachable!(),
138134
};
139-
Some(cx.context.new_function(
135+
cx.context.new_function(
140136
None,
141137
FunctionType::Extern,
142138
f128_type,
143139
&[cx.context.new_parameter(None, f128_type, "a")],
144140
func_name,
145141
false,
146-
))
142+
)
147143
}
148144

149145
fn get_simple_function_f128_2args<'gcc, 'tcx>(
150146
cx: &CodegenCx<'gcc, 'tcx>,
151147
name: Symbol,
152-
) -> Option<Function<'gcc>> {
153-
if !cx.supports_f128_type {
154-
return None;
155-
}
156-
148+
) -> Function<'gcc> {
157149
let f128_type = cx.type_f128();
158150
let func_name = match name {
159151
// GCC doesn't have the intrinsic we want so we use the compiler-builtins one
@@ -164,9 +156,9 @@ fn get_simple_function_f128_2args<'gcc, 'tcx>(
164156
sym::maxnumf128 => "fmaxf128",
165157
sym::minnumf128 => "fminf128",
166158
sym::copysignf128 => "copysignf128",
167-
_ => return None,
159+
_ => unreachable!(),
168160
};
169-
Some(cx.context.new_function(
161+
cx.context.new_function(
170162
None,
171163
FunctionType::Extern,
172164
f128_type,
@@ -176,7 +168,7 @@ fn get_simple_function_f128_2args<'gcc, 'tcx>(
176168
],
177169
func_name,
178170
false,
179-
))
171+
)
180172
}
181173

182174
fn f16_builtin<'gcc, 'tcx>(
@@ -223,11 +215,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
223215
let fn_args = instance.args;
224216

225217
let simple = get_simple_intrinsic(self, name);
226-
// TODO(antoyo): Only call get_simple_function_f128 and get_simple_function_f128_2args when
227-
// it is the symbols for the supported f128 builtins.
228-
let simple_func = get_simple_function(self, name)
229-
.or_else(|| get_simple_function_f128(self, name))
230-
.or_else(|| get_simple_function_f128_2args(self, name));
218+
let simple_func = get_simple_function(self, name);
231219

232220
let value = match name {
233221
_ if simple.is_some() => {
@@ -258,6 +246,34 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
258246
| sym::round_ties_even_f16
259247
| sym::sqrtf16
260248
| sym::truncf16 => f16_builtin(self, name, args),
249+
sym::ceilf128
250+
| sym::fabsf128
251+
| sym::floorf128
252+
| sym::truncf128
253+
| sym::roundf128
254+
| sym::round_ties_even_f128
255+
| sym::sqrtf128
256+
if self.cx.supports_f128_type =>
257+
{
258+
self.cx.context.new_call(
259+
self.location,
260+
get_simple_function_f128(self, name),
261+
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
262+
)
263+
}
264+
sym::maximumf128
265+
| sym::minimumf128
266+
| sym::maxnumf128
267+
| sym::minnumf128
268+
| sym::copysignf128
269+
if self.cx.supports_f128_type =>
270+
{
271+
self.cx.context.new_call(
272+
self.location,
273+
get_simple_function_f128_2args(self, name),
274+
&args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
275+
)
276+
}
261277
sym::fmaf128 => {
262278
let f128_type = self.cx.type_f128();
263279
let func = self.cx.context.new_function(

0 commit comments

Comments
 (0)