authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-22 13:14:07-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-12-22 13:14:07-05:00
loge44a11341d21a14441c5607efa04b9c1be9baf5a
treee7e99f962ae1cda44b0fd8ec27a1e37ea933a918
parent0e7fb69bea4d2b50ab352b71de87a563b57a645a

std.math: remove unnecessary inline calls and

workaround windows 32 bit test failure See #537

31 files changed, 71 insertions(+), 71 deletions(-)

std/math/acos.zig+2-2
......@@ -8,8 +8,8 @@ const assert = @import("../debug.zig").assert;
88pub fn acos(x: var) -> @typeOf(x) {
99 const T = @typeOf(x);
1010 return switch (T) {
11 f32 => @inlineCall(acos32, x),
12 f64 => @inlineCall(acos64, x),
11 f32 => acos32(x),
12 f64 => acos64(x),
1313 else => @compileError("acos not implemented for " ++ @typeName(T)),
1414 };
1515}
std/math/acosh.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn acosh(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(acosh32, x),
14 f64 => @inlineCall(acosh64, x),
13 f32 => acosh32(x),
14 f64 => acosh64(x),
1515 else => @compileError("acosh not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/asin.zig+2-2
......@@ -9,8 +9,8 @@ const assert = @import("../debug.zig").assert;
99pub fn asin(x: var) -> @typeOf(x) {
1010 const T = @typeOf(x);
1111 return switch (T) {
12 f32 => @inlineCall(asin32, x),
13 f64 => @inlineCall(asin64, x),
12 f32 => asin32(x),
13 f64 => asin64(x),
1414 else => @compileError("asin not implemented for " ++ @typeName(T)),
1515 };
1616}
std/math/asinh.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn asinh(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(asinh32, x),
14 f64 => @inlineCall(asinh64, x),
13 f32 => asinh32(x),
14 f64 => asinh64(x),
1515 else => @compileError("asinh not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/atan.zig+11-11
......@@ -9,8 +9,8 @@ const assert = @import("../debug.zig").assert;
99pub fn atan(x: var) -> @typeOf(x) {
1010 const T = @typeOf(x);
1111 return switch (T) {
12 f32 => @inlineCall(atan32, x),
13 f64 => @inlineCall(atan64, x),
12 f32 => atan32(x),
13 f64 => atan64(x),
1414 else => @compileError("atan not implemented for " ++ @typeName(T)),
1515 };
1616}
......@@ -99,11 +99,11 @@ fn atan32(x_: f32) -> f32 {
9999 const s1 = z * (aT[0] + w * (aT[2] + w * aT[4]));
100100 const s2 = w * (aT[1] + w * aT[3]);
101101
102 if (id == null) {
103 return x - x * (s1 + s2);
104 } else {
105 const zz = atanhi[??id] - ((x * (s1 + s2) - atanlo[??id]) - x);
102 if (id) |id_value| {
103 const zz = atanhi[id_value] - ((x * (s1 + s2) - atanlo[id_value]) - x);
106104 return if (sign != 0) -zz else zz;
105 } else {
106 return x - x * (s1 + s2);
107107 }
108108}
109109
......@@ -198,16 +198,16 @@ fn atan64(x_: f64) -> f64 {
198198 const s1 = z * (aT[0] + w * (aT[2] + w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10])))));
199199 const s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));
200200
201 if (id == null) {
202 return x - x * (s1 + s2);
203 } else {
204 const zz = atanhi[??id] - ((x * (s1 + s2) - atanlo[??id]) - x);
201 if (id) |id_value| {
202 const zz = atanhi[id_value] - ((x * (s1 + s2) - atanlo[id_value]) - x);
205203 return if (sign != 0) -zz else zz;
204 } else {
205 return x - x * (s1 + s2);
206206 }
207207}
208208
209209test "math.atan" {
210 assert(atan(f32(0.2)) == atan32(0.2));
210 assert(@bitCast(u32, atan(f32(0.2))) == @bitCast(u32, atan32(0.2)));
211211 assert(atan(f64(0.2)) == atan64(0.2));
212212}
213213
std/math/atan2.zig+2-2
......@@ -23,8 +23,8 @@ const assert = @import("../debug.zig").assert;
2323
2424fn atan2(comptime T: type, x: T, y: T) -> T {
2525 return switch (T) {
26 f32 => @inlineCall(atan2_32, x, y),
27 f64 => @inlineCall(atan2_64, x, y),
26 f32 => atan2_32(x, y),
27 f64 => atan2_64(x, y),
2828 else => @compileError("atan2 not implemented for " ++ @typeName(T)),
2929 };
3030}
std/math/atanh.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn atanh(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(atanh_32, x),
14 f64 => @inlineCall(atanh_64, x),
13 f32 => atanh_32(x),
14 f64 => atanh_64(x),
1515 else => @compileError("atanh not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/cbrt.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn cbrt(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(cbrt32, x),
14 f64 => @inlineCall(cbrt64, x),
13 f32 => cbrt32(x),
14 f64 => cbrt64(x),
1515 else => @compileError("cbrt not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/ceil.zig+2-2
......@@ -11,8 +11,8 @@ const assert = @import("../debug.zig").assert;
1111pub fn ceil(x: var) -> @typeOf(x) {
1212 const T = @typeOf(x);
1313 return switch (T) {
14 f32 => @inlineCall(ceil32, x),
15 f64 => @inlineCall(ceil64, x),
14 f32 => ceil32(x),
15 f64 => ceil64(x),
1616 else => @compileError("ceil not implemented for " ++ @typeName(T)),
1717 };
1818}
std/math/copysign.zig+2-2
......@@ -3,8 +3,8 @@ const assert = @import("../debug.zig").assert;
33
44pub fn copysign(comptime T: type, x: T, y: T) -> T {
55 return switch (T) {
6 f32 => @inlineCall(copysign32, x, y),
7 f64 => @inlineCall(copysign64, x, y),
6 f32 => copysign32(x, y),
7 f64 => copysign64(x, y),
88 else => @compileError("copysign not implemented for " ++ @typeName(T)),
99 };
1010}
std/math/cos.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn cos(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(cos32, x),
14 f64 => @inlineCall(cos64, x),
13 f32 => cos32(x),
14 f64 => cos64(x),
1515 else => @compileError("cos not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/cosh.zig+2-2
......@@ -12,8 +12,8 @@ const assert = @import("../debug.zig").assert;
1212pub fn cosh(x: var) -> @typeOf(x) {
1313 const T = @typeOf(x);
1414 return switch (T) {
15 f32 => @inlineCall(cosh32, x),
16 f64 => @inlineCall(cosh64, x),
15 f32 => cosh32(x),
16 f64 => cosh64(x),
1717 else => @compileError("cosh not implemented for " ++ @typeName(T)),
1818 };
1919}
std/math/exp.zig+2-2
......@@ -9,8 +9,8 @@ const assert = @import("../debug.zig").assert;
99pub fn exp(x: var) -> @typeOf(x) {
1010 const T = @typeOf(x);
1111 return switch (T) {
12 f32 => @inlineCall(exp32, x),
13 f64 => @inlineCall(exp64, x),
12 f32 => exp32(x),
13 f64 => exp64(x),
1414 else => @compileError("exp not implemented for " ++ @typeName(T)),
1515 };
1616}
std/math/exp2.zig+2-2
......@@ -9,8 +9,8 @@ const assert = @import("../debug.zig").assert;
99pub fn exp2(x: var) -> @typeOf(x) {
1010 const T = @typeOf(x);
1111 return switch (T) {
12 f32 => @inlineCall(exp2_32, x),
13 f64 => @inlineCall(exp2_64, x),
12 f32 => exp2_32(x),
13 f64 => exp2_64(x),
1414 else => @compileError("exp2 not implemented for " ++ @typeName(T)),
1515 };
1616}
std/math/expm1.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn expm1(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(expm1_32, x),
14 f64 => @inlineCall(expm1_64, x),
13 f32 => expm1_32(x),
14 f64 => expm1_64(x),
1515 else => @compileError("exp1m not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/fabs.zig+2-2
......@@ -9,8 +9,8 @@ const assert = @import("../debug.zig").assert;
99pub fn fabs(x: var) -> @typeOf(x) {
1010 const T = @typeOf(x);
1111 return switch (T) {
12 f32 => @inlineCall(fabs32, x),
13 f64 => @inlineCall(fabs64, x),
12 f32 => fabs32(x),
13 f64 => fabs64(x),
1414 else => @compileError("fabs not implemented for " ++ @typeName(T)),
1515 };
1616}
std/math/floor.zig+2-2
......@@ -11,8 +11,8 @@ const math = @import("index.zig");
1111pub fn floor(x: var) -> @typeOf(x) {
1212 const T = @typeOf(x);
1313 return switch (T) {
14 f32 => @inlineCall(floor32, x),
15 f64 => @inlineCall(floor64, x),
14 f32 => floor32(x),
15 f64 => floor64(x),
1616 else => @compileError("floor not implemented for " ++ @typeName(T)),
1717 };
1818}
std/math/fma.zig+2-2
......@@ -3,8 +3,8 @@ const assert = @import("../debug.zig").assert;
33
44pub fn fma(comptime T: type, x: T, y: T, z: T) -> T {
55 return switch (T) {
6 f32 => @inlineCall(fma32, x, y, z),
7 f64 => @inlineCall(fma64, x, y ,z),
6 f32 => fma32(x, y, z),
7 f64 => fma64(x, y ,z),
88 else => @compileError("fma not implemented for " ++ @typeName(T)),
99 };
1010}
std/math/frexp.zig+2-2
......@@ -19,8 +19,8 @@ pub const frexp64_result = frexp_result(f64);
1919pub fn frexp(x: var) -> frexp_result(@typeOf(x)) {
2020 const T = @typeOf(x);
2121 return switch (T) {
22 f32 => @inlineCall(frexp32, x),
23 f64 => @inlineCall(frexp64, x),
22 f32 => frexp32(x),
23 f64 => frexp64(x),
2424 else => @compileError("frexp not implemented for " ++ @typeName(T)),
2525 };
2626}
std/math/hypot.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010
1111pub fn hypot(comptime T: type, x: T, y: T) -> T {
1212 return switch (T) {
13 f32 => @inlineCall(hypot32, x, y),
14 f64 => @inlineCall(hypot64, x, y),
13 f32 => hypot32(x, y),
14 f64 => hypot64(x, y),
1515 else => @compileError("hypot not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/ilogb.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn ilogb(x: var) -> i32 {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(ilogb32, x),
14 f64 => @inlineCall(ilogb64, x),
13 f32 => ilogb32(x),
14 f64 => ilogb64(x),
1515 else => @compileError("ilogb not implemented for " ++ @typeName(T)),
1616 };
1717}
std/math/log1p.zig+2-2
......@@ -12,8 +12,8 @@ const assert = @import("../debug.zig").assert;
1212pub fn log1p(x: var) -> @typeOf(x) {
1313 const T = @typeOf(x);
1414 return switch (T) {
15 f32 => @inlineCall(log1p_32, x),
16 f64 => @inlineCall(log1p_64, x),
15 f32 => log1p_32(x),
16 f64 => log1p_64(x),
1717 else => @compileError("log1p not implemented for " ++ @typeName(T)),
1818 };
1919}
std/math/modf.zig+2-2
......@@ -18,8 +18,8 @@ pub const modf64_result = modf_result(f64);
1818pub fn modf(x: var) -> modf_result(@typeOf(x)) {
1919 const T = @typeOf(x);
2020 return switch (T) {
21 f32 => @inlineCall(modf32, x),
22 f64 => @inlineCall(modf64, x),
21 f32 => modf32(x),
22 f64 => modf64(x),
2323 else => @compileError("modf not implemented for " ++ @typeName(T)),
2424 };
2525}
std/math/round.zig+2-2
......@@ -11,8 +11,8 @@ const math = @import("index.zig");
1111pub fn round(x: var) -> @typeOf(x) {
1212 const T = @typeOf(x);
1313 return switch (T) {
14 f32 => @inlineCall(round32, x),
15 f64 => @inlineCall(round64, x),
14 f32 => round32(x),
15 f64 => round64(x),
1616 else => @compileError("round not implemented for " ++ @typeName(T)),
1717 };
1818}
std/math/scalbn.zig+2-2
......@@ -4,8 +4,8 @@ const assert = @import("../debug.zig").assert;
44pub fn scalbn(x: var, n: i32) -> @typeOf(x) {
55 const T = @typeOf(x);
66 return switch (T) {
7 f32 => @inlineCall(scalbn32, x, n),
8 f64 => @inlineCall(scalbn64, x, n),
7 f32 => scalbn32(x, n),
8 f64 => scalbn64(x, n),
99 else => @compileError("scalbn not implemented for " ++ @typeName(T)),
1010 };
1111}
std/math/signbit.zig+2-2
......@@ -4,8 +4,8 @@ const assert = @import("../debug.zig").assert;
44pub fn signbit(x: var) -> bool {
55 const T = @typeOf(x);
66 return switch (T) {
7 f32 => @inlineCall(signbit32, x),
8 f64 => @inlineCall(signbit64, x),
7 f32 => signbit32(x),
8 f64 => signbit64(x),
99 else => @compileError("signbit not implemented for " ++ @typeName(T)),
1010 };
1111}
std/math/sin.zig+2-2
......@@ -11,8 +11,8 @@ const assert = @import("../debug.zig").assert;
1111pub fn sin(x: var) -> @typeOf(x) {
1212 const T = @typeOf(x);
1313 return switch (T) {
14 f32 => @inlineCall(sin32, x),
15 f64 => @inlineCall(sin64, x),
14 f32 => sin32(x),
15 f64 => sin64(x),
1616 else => @compileError("sin not implemented for " ++ @typeName(T)),
1717 };
1818}
std/math/sinh.zig+2-2
......@@ -12,8 +12,8 @@ const expo2 = @import("expo2.zig").expo2;
1212pub fn sinh(x: var) -> @typeOf(x) {
1313 const T = @typeOf(x);
1414 return switch (T) {
15 f32 => @inlineCall(sinh32, x),
16 f64 => @inlineCall(sinh64, x),
15 f32 => sinh32(x),
16 f64 => sinh64(x),
1717 else => @compileError("sinh not implemented for " ++ @typeName(T)),
1818 };
1919}
std/math/tan.zig+2-2
......@@ -11,8 +11,8 @@ const assert = @import("../debug.zig").assert;
1111pub fn tan(x: var) -> @typeOf(x) {
1212 const T = @typeOf(x);
1313 return switch (T) {
14 f32 => @inlineCall(tan32, x),
15 f64 => @inlineCall(tan64, x),
14 f32 => tan32(x),
15 f64 => tan64(x),
1616 else => @compileError("tan not implemented for " ++ @typeName(T)),
1717 };
1818}
std/math/tanh.zig+2-2
......@@ -12,8 +12,8 @@ const expo2 = @import("expo2.zig").expo2;
1212pub fn tanh(x: var) -> @typeOf(x) {
1313 const T = @typeOf(x);
1414 return switch (T) {
15 f32 => @inlineCall(tanh32, x),
16 f64 => @inlineCall(tanh64, x),
15 f32 => tanh32(x),
16 f64 => tanh64(x),
1717 else => @compileError("tanh not implemented for " ++ @typeName(T)),
1818 };
1919}
std/math/trunc.zig+2-2
......@@ -10,8 +10,8 @@ const assert = @import("../debug.zig").assert;
1010pub fn trunc(x: var) -> @typeOf(x) {
1111 const T = @typeOf(x);
1212 return switch (T) {
13 f32 => @inlineCall(trunc32, x),
14 f64 => @inlineCall(trunc64, x),
13 f32 => trunc32(x),
14 f64 => trunc64(x),
1515 else => @compileError("trunc not implemented for " ++ @typeName(T)),
1616 };
1717}