mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-14 09:52:23 -07:00
Fix min/max for floats
This commit is contained in:
+9
-7
@@ -1630,7 +1630,7 @@ irValue *ir_emit_call(irProcedure *p, irValue *value, irValue **args, isize arg_
|
||||
if (pt->Proc.c_vararg) {
|
||||
GB_ASSERT(param_count-1 <= arg_count);
|
||||
} else {
|
||||
GB_ASSERT(param_count == arg_count);
|
||||
GB_ASSERT_MSG(param_count == arg_count, "%td == %td", param_count, arg_count);
|
||||
}
|
||||
for (isize i = 0; i < param_count; i++) {
|
||||
Entity *e = pt->Proc.params->Tuple.variables[i];
|
||||
@@ -3954,11 +3954,12 @@ irValue *ir_emit_min(irProcedure *proc, Type *t, irValue *x, irValue *y) {
|
||||
if (is_type_float(t)) {
|
||||
gbAllocator a = proc->module->allocator;
|
||||
i64 sz = 8*type_size_of(a, t);
|
||||
irValue **args = gb_alloc_array(a, irValue *, 1);
|
||||
irValue **args = gb_alloc_array(a, irValue *, 2);
|
||||
args[0] = x;
|
||||
args[1] = y;
|
||||
switch (sz) {
|
||||
case 32: return ir_emit_global_call(proc, "__min_f32", args, 1);
|
||||
case 64: return ir_emit_global_call(proc, "__min_f64", args, 1);
|
||||
case 32: return ir_emit_global_call(proc, "__min_f32", args, 2);
|
||||
case 64: return ir_emit_global_call(proc, "__min_f64", args, 2);
|
||||
}
|
||||
GB_PANIC("Unknown float type");
|
||||
}
|
||||
@@ -3971,11 +3972,12 @@ irValue *ir_emit_max(irProcedure *proc, Type *t, irValue *x, irValue *y) {
|
||||
if (is_type_float(t)) {
|
||||
gbAllocator a = proc->module->allocator;
|
||||
i64 sz = 8*type_size_of(a, t);
|
||||
irValue **args = gb_alloc_array(a, irValue *, 1);
|
||||
irValue **args = gb_alloc_array(a, irValue *, 2);
|
||||
args[0] = x;
|
||||
args[1] = y;
|
||||
switch (sz) {
|
||||
case 32: return ir_emit_global_call(proc, "__max_f32", args, 1);
|
||||
case 64: return ir_emit_global_call(proc, "__max_f64", args, 1);
|
||||
case 32: return ir_emit_global_call(proc, "__max_f32", args, 2);
|
||||
case 64: return ir_emit_global_call(proc, "__max_f64", args, 2);
|
||||
}
|
||||
GB_PANIC("Unknown float type");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user