diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index 4e35da47f..5bb0f18de 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -403,22 +403,22 @@ abs_f64 :: #force_inline proc "contextless" (x: f64) -> f64 { return -x if x < 0 else x; } -min_f16 :: proc(a, b: f16) -> f16 { +min_f16 :: #force_inline proc "contextless" (a, b: f16) -> f16 { return a if a < b else b; } -min_f32 :: proc(a, b: f32) -> f32 { +min_f32 :: #force_inline proc "contextless" (a, b: f32) -> f32 { return a if a < b else b; } -min_f64 :: proc(a, b: f64) -> f64 { +min_f64 :: #force_inline proc "contextless" (a, b: f64) -> f64 { return a if a < b else b; } -max_f16 :: proc(a, b: f16) -> f16 { +max_f16 :: #force_inline proc "contextless" (a, b: f16) -> f16 { return a if a > b else b; } -max_f32 :: proc(a, b: f32) -> f32 { +max_f32 :: #force_inline proc "contextless" (a, b: f32) -> f32 { return a if a > b else b; } -max_f64 :: proc(a, b: f64) -> f64 { +max_f64 :: #force_inline proc "contextless" (a, b: f64) -> f64 { return a if a > b else b; } diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index c67679f1c..b6dadb09a 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1184,6 +1184,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 { Type *bt = base_type(operands[0].type); + if (are_types_identical(bt, t_f16)) add_package_dependency(c, "runtime", "min_f16"); if (are_types_identical(bt, t_f32)) add_package_dependency(c, "runtime", "min_f32"); if (are_types_identical(bt, t_f64)) add_package_dependency(c, "runtime", "min_f64"); @@ -1364,6 +1365,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 { Type *bt = base_type(operands[0].type); + if (are_types_identical(bt, t_f16)) add_package_dependency(c, "runtime", "max_f16"); if (are_types_identical(bt, t_f32)) add_package_dependency(c, "runtime", "max_f32"); if (are_types_identical(bt, t_f64)) add_package_dependency(c, "runtime", "max_f64"); diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index c31d1f34f..dbc059d5f 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -5600,37 +5600,11 @@ LLVMValueRef lb_const_f32(lbModule *m, f32 f, Type *type=t_f32) { lbValue lb_emit_min(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - - if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make(permanent_allocator(), 2); - args[0] = x; - args[1] = y; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "min_f16", args); - case 32: return lb_emit_runtime_call(p, "min_f32", args); - case 64: return lb_emit_runtime_call(p, "min_f64", args); - } - GB_PANIC("Unknown float type"); - } return lb_emit_select(p, lb_emit_comp(p, Token_Lt, x, y), x, y); } lbValue lb_emit_max(lbProcedure *p, Type *t, lbValue x, lbValue y) { x = lb_emit_conv(p, x, t); y = lb_emit_conv(p, y, t); - - if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make(permanent_allocator(), 2); - args[0] = x; - args[1] = y; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "max_f16", args); - case 32: return lb_emit_runtime_call(p, "max_f32", args); - case 64: return lb_emit_runtime_call(p, "max_f64", args); - } - GB_PANIC("Unknown float type"); - } return lb_emit_select(p, lb_emit_comp(p, Token_Gt, x, y), x, y); } @@ -9307,16 +9281,6 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, case 128: return lb_emit_runtime_call(p, "abs_complex128", args); } GB_PANIC("Unknown complex type"); - } else if (is_type_float(t)) { - i64 sz = 8*type_size_of(t); - auto args = array_make(permanent_allocator(), 1); - args[0] = x; - switch (sz) { - case 16: return lb_emit_runtime_call(p, "abs_f16", args); - case 32: return lb_emit_runtime_call(p, "abs_f32", args); - case 64: return lb_emit_runtime_call(p, "abs_f64", args); - } - GB_PANIC("Unknown float type"); } lbValue zero = lb_const_nil(p->module, t); lbValue cond = lb_emit_comp(p, Token_Lt, x, zero);