| author | |
| committer | |
| log | 5518a0aff2ab023e9021b74a0a14eb9fcfc094cc |
| tree | e639d7ec9170634de9503d4a1886b13552df4610 |
| parent | 4ee91bb8a83fbddaf266500196525308525e2605 |
libc requires this to use `long double` which is sometimes the same as
f128, sometimes not.
Also for an unknown reason, aarch64 is getting an invalid result for the
`@mulAdd` behavior test for f128. See #9900.3 files changed, 10 insertions(+), 1 deletions(-)
lib/std/math/fma.zig+4| ... | @@ -15,6 +15,10 @@ pub fn fma(comptime T: type, x: T, y: T, z: T) T { | ... | @@ -15,6 +15,10 @@ pub fn fma(comptime T: type, x: T, y: T, z: T) T { |
| 15 | f32 => fma32(x, y, z), | 15 | f32 => fma32(x, y, z), |
| 16 | f64 => fma64(x, y, z), | 16 | f64 => fma64(x, y, z), |
| 17 | f128 => fma128(x, y, z), | 17 | f128 => fma128(x, y, z), |
| 18 | |||
| 19 | // TODO this is not correct for some targets | ||
| 20 | c_longdouble => @floatCast(c_longdouble, fma128(x, y, z)), | ||
| 21 | |||
| 18 | else => @compileError("fma not implemented for " ++ @typeName(T)), | 22 | else => @compileError("fma not implemented for " ++ @typeName(T)), |
| 19 | }; | 23 | }; |
| 20 | } | 24 | } |
lib/std/special/c_stage1.zig+4| ... | @@ -656,6 +656,10 @@ export fn ceil(x: f64) f64 { | ... | @@ -656,6 +656,10 @@ export fn ceil(x: f64) f64 { |
| 656 | return math.ceil(x); | 656 | return math.ceil(x); |
| 657 | } | 657 | } |
| 658 | 658 | ||
| 659 | export fn fmal(a: c_longdouble, b: c_longdouble, c: c_longdouble) c_longdouble { | ||
| 660 | return math.fma(c_longdouble, a, b, c); | ||
| 661 | } | ||
| 662 | |||
| 659 | export fn fma(a: f64, b: f64, c: f64) f64 { | 663 | export fn fma(a: f64, b: f64, c: f64) f64 { |
| 660 | return math.fma(f64, a, b, c); | 664 | return math.fma(f64, a, b, c); |
| 661 | } | 665 | } |
test/behavior/muladd.zig+2-1| ... | @@ -24,7 +24,8 @@ fn testMulAdd() !void { | ... | @@ -24,7 +24,8 @@ fn testMulAdd() !void { |
| 24 | var c: f64 = 6.25; | 24 | var c: f64 = 6.25; |
| 25 | try expect(@mulAdd(f64, a, b, c) == 20); | 25 | try expect(@mulAdd(f64, a, b, c) == 20); |
| 26 | } | 26 | } |
| 27 | { | 27 | // TODO https://github.com/ziglang/zig/issues/9900 |
| 28 | if (@import("builtin").cpu.arch != .aarch64) { | ||
| 28 | var a: f16 = 5.5; | 29 | var a: f16 = 5.5; |
| 29 | var b: f128 = 2.5; | 30 | var b: f128 = 2.5; |
| 30 | var c: f128 = 6.25; | 31 | var c: f128 = 6.25; |