diff --git a/lib/compiler_rt/ceil.zig b/lib/compiler_rt/ceil.zig index 41ce1c00d82d14a7688236ef35a67984b61cbbf7..881a5a64709c9f4c1b3f2c15706e84561c4ef08a 100644 --- a/lib/compiler_rt/ceil.zig +++ b/lib/compiler_rt/ceil.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -47,14 +48,14 @@ pub fn ceilf(x: f32) callconv(.C) f32 { if (u & m == 0) { return x; } - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 31 == 0) { u += m; } u &= ~m; return @bitCast(u); } else { - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 31 != 0) { return -0.0; } else { @@ -81,7 +82,7 @@ pub fn ceil(x: f64) callconv(.C) f64 { } if (e <= 0x3FF - 1) { - math.doNotOptimizeAway(y); + mem.doNotOptimizeAway(y); if (u >> 63 != 0) { return -0.0; } else { @@ -115,7 +116,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 { } if (e <= 0x3FFF - 1) { - math.doNotOptimizeAway(y); + mem.doNotOptimizeAway(y); if (u >> 127 != 0) { return -0.0; } else { diff --git a/lib/compiler_rt/cos.zig b/lib/compiler_rt/cos.zig index aaf8faa2f34ee5753ab980dfed130e87143eb729..2248a68230194d69880655eb7225c30eda1c0f6e 100644 --- a/lib/compiler_rt/cos.zig +++ b/lib/compiler_rt/cos.zig @@ -1,5 +1,6 @@ const std = @import("std"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -40,7 +41,7 @@ pub fn cosf(x: f32) callconv(.C) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x != 0 - math.doNotOptimizeAway(x + 0x1p120); + mem.doNotOptimizeAway(x + 0x1p120); return 1.0; } return trig.__cosdf(x); @@ -91,7 +92,7 @@ pub fn cos(x: f64) callconv(.C) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2) // raise inexact if x!=0 - math.doNotOptimizeAway(x + 0x1p120); + mem.doNotOptimizeAway(x + 0x1p120); return 1.0; } return trig.__cos(x, 0); diff --git a/lib/compiler_rt/exp.zig b/lib/compiler_rt/exp.zig index 6b8ac040764001927c33ef07ec3cde30eb05e585..4bcb0cb5f00f0f3f956f7359428b9af132efe7da 100644 --- a/lib/compiler_rt/exp.zig +++ b/lib/compiler_rt/exp.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -58,7 +59,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { return x * 0x1.0p127; } if (sign != 0) { - math.doNotOptimizeAway(-0x1.0p-149 / x); // overflow + mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow // x <= -103.972084 if (hx >= 0x42CFF1B5) { return 0; @@ -90,7 +91,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { hi = x; lo = 0; } else { - math.doNotOptimizeAway(0x1.0p127 + x); // inexact + mem.doNotOptimizeAway(0x1.0p127 + x); // inexact return 1 + x; } @@ -141,7 +142,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { } if (x < -708.39641853226410622) { // underflow if x != -inf - // math.doNotOptimizeAway(@as(f32, -0x1.0p-149 / x)); + // mem.doNotOptimizeAway(@as(f32, -0x1.0p-149 / x)); if (x < -745.13321910194110842) { return 0; } @@ -174,7 +175,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { lo = 0; } else { // inexact if x != 0 - // math.doNotOptimizeAway(0x1.0p1023 + x); + // mem.doNotOptimizeAway(0x1.0p1023 + x); return 1 + x; } diff --git a/lib/compiler_rt/exp2.zig b/lib/compiler_rt/exp2.zig index 5ffb73c4f55d07bf9ba6c45f2f91e6e24a7ce70e..f094f93328c7c142991c81cec485b483326dae12 100644 --- a/lib/compiler_rt/exp2.zig +++ b/lib/compiler_rt/exp2.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -54,7 +55,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 { // x < -126 if (u >= 0x80000000) { if (u >= 0xC3160000 or u & 0x000FFFF != 0) { - math.doNotOptimizeAway(-0x1.0p-149 / x); + mem.doNotOptimizeAway(-0x1.0p-149 / x); } // x <= -150 if (u >= 0x3160000) { @@ -119,7 +120,7 @@ pub fn exp2(x: f64) callconv(.C) f64 { if (ux >> 63 != 0) { // underflow if (x <= -1075 or x - 0x1.0p52 + 0x1.0p52 != x) { - math.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); + mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); } if (x <= -1075) { return 0; diff --git a/lib/compiler_rt/floor.zig b/lib/compiler_rt/floor.zig index 5eb428e8a5ad038a306c7c9e45862d8103ac71be..a2614c80476ab58606056d058bc8964d97ef679a 100644 --- a/lib/compiler_rt/floor.zig +++ b/lib/compiler_rt/floor.zig @@ -7,6 +7,7 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const arch = builtin.cpu.arch; const common = @import("common.zig"); @@ -44,13 +45,13 @@ pub fn __floorh(x: f16) callconv(.C) f16 { if (u & m == 0) { return x; } - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 15 != 0) { u += m; } return @bitCast(u & ~m); } else { - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 15 == 0) { return 0.0; } else { @@ -78,13 +79,13 @@ pub fn floorf(x: f32) callconv(.C) f32 { if (u & m == 0) { return x; } - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 31 != 0) { u += m; } return @bitCast(u & ~m); } else { - math.doNotOptimizeAway(x + 0x1.0p120); + mem.doNotOptimizeAway(x + 0x1.0p120); if (u >> 31 == 0) { return 0.0; } else { @@ -111,7 +112,7 @@ pub fn floor(x: f64) callconv(.C) f64 { } if (e <= 0x3FF - 1) { - math.doNotOptimizeAway(y); + mem.doNotOptimizeAway(y); if (u >> 63 != 0) { return -1.0; } else { @@ -145,7 +146,7 @@ pub fn floorq(x: f128) callconv(.C) f128 { } if (e <= 0x3FFF - 1) { - math.doNotOptimizeAway(y); + mem.doNotOptimizeAway(y); if (u >> 127 != 0) { return -1.0; } else { diff --git a/lib/compiler_rt/round.zig b/lib/compiler_rt/round.zig index c702909e5d9e108665ca14dc92891c634c899c93..9f91ac4bc98a811ff3bf93052ceaee2eba5e91e8 100644 --- a/lib/compiler_rt/round.zig +++ b/lib/compiler_rt/round.zig @@ -7,6 +7,7 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const arch = builtin.cpu.arch; const common = @import("common.zig"); @@ -45,7 +46,7 @@ pub fn roundf(x_: f32) callconv(.C) f32 { x = -x; } if (e < 0x7F - 1) { - math.doNotOptimizeAway(x + f32_toint); + mem.doNotOptimizeAway(x + f32_toint); return 0 * @as(f32, @bitCast(u)); } @@ -80,7 +81,7 @@ pub fn round(x_: f64) callconv(.C) f64 { x = -x; } if (e < 0x3ff - 1) { - math.doNotOptimizeAway(x + f64_toint); + mem.doNotOptimizeAway(x + f64_toint); return 0 * @as(f64, @bitCast(u)); } @@ -120,7 +121,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 { x = -x; } if (e < 0x3FFF - 1) { - math.doNotOptimizeAway(x + f128_toint); + mem.doNotOptimizeAway(x + f128_toint); return 0 * @as(f128, @bitCast(u)); } diff --git a/lib/compiler_rt/sin.zig b/lib/compiler_rt/sin.zig index b0180953e08433faa19a1def5320dc2bfdd684e7..1155a187d36c4c3d46c4f24060120fd6d1d93984 100644 --- a/lib/compiler_rt/sin.zig +++ b/lib/compiler_rt/sin.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -48,7 +49,7 @@ pub fn sinf(x: f32) callconv(.C) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x!=0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); return x; } return trig.__sindf(x); @@ -97,7 +98,7 @@ pub fn sin(x: f64) callconv(.C) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e500000) { // |x| < 2**-26 // raise inexact if x != 0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); return x; } return trig.__sin(x, 0.0, 0); diff --git a/lib/compiler_rt/sincos.zig b/lib/compiler_rt/sincos.zig index 3a4eaced26002c01213da81a054e7567eafb1608..9bfa9260d6be66e6b455edaad62a84e969737754 100644 --- a/lib/compiler_rt/sincos.zig +++ b/lib/compiler_rt/sincos.zig @@ -2,6 +2,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const trig = @import("trig.zig"); const rem_pio2 = @import("rem_pio2.zig").rem_pio2; const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; @@ -45,7 +46,7 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.C) void { // |x| < 2**-12 if (ix < 0x39800000) { // raise inexact if x!=0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); r_sin.* = x; r_cos.* = 1.0; return; @@ -133,7 +134,7 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.C) void { // if |x| < 2**-27 * sqrt(2) if (ix < 0x3e46a09e) { // raise inexact if x != 0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); r_sin.* = x; r_cos.* = 1.0; return; @@ -231,7 +232,7 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { if (se < 0x3fff - math.floatFractionalBits(F) - 1) { // raise underflow if subnormal if (se == 0) { - math.doNotOptimizeAway(x * 0x1p-120); + mem.doNotOptimizeAway(x * 0x1p-120); } r_sin.* = x; // raise inexact if x!=0 diff --git a/lib/compiler_rt/tan.zig b/lib/compiler_rt/tan.zig index 367883754f6a20853038f1b708aaf08bb2066b9a..ccaa5e2f025c03d16636e8db17ba541e74352cff 100644 --- a/lib/compiler_rt/tan.zig +++ b/lib/compiler_rt/tan.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const kernel = @import("trig.zig"); @@ -50,7 +51,7 @@ pub fn tanf(x: f32) callconv(.C) f32 { if (ix <= 0x3f490fda) { // |x| ~<= pi/4 if (ix < 0x39800000) { // |x| < 2**-12 // raise inexact if x!=0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); return x; } return kernel.__tandf(x, false); @@ -88,7 +89,7 @@ pub fn tan(x: f64) callconv(.C) f64 { if (ix <= 0x3fe921fb) { if (ix < 0x3e400000) { // |x| < 2**-27 // raise inexact if x!=0 and underflow if subnormal - math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); + mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); return x; } return kernel.__tan(x, 0.0, false); diff --git a/lib/compiler_rt/trunc.zig b/lib/compiler_rt/trunc.zig index 80b7a2bf892123b7e5b308d9c57f0d0ca2b2f280..247bd982861b0bf266443e7411038ceae95db1bd 100644 --- a/lib/compiler_rt/trunc.zig +++ b/lib/compiler_rt/trunc.zig @@ -8,6 +8,7 @@ const std = @import("std"); const builtin = @import("builtin"); const arch = builtin.cpu.arch; const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const common = @import("common.zig"); @@ -46,7 +47,7 @@ pub fn truncf(x: f32) callconv(.C) f32 { if (u & m == 0) { return x; } else { - math.doNotOptimizeAway(x + 0x1p120); + mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } @@ -67,7 +68,7 @@ pub fn trunc(x: f64) callconv(.C) f64 { if (u & m == 0) { return x; } else { - math.doNotOptimizeAway(x + 0x1p120); + mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } @@ -93,7 +94,7 @@ pub fn truncq(x: f128) callconv(.C) f128 { if (u & m == 0) { return x; } else { - math.doNotOptimizeAway(x + 0x1p120); + mem.doNotOptimizeAway(x + 0x1p120); return @bitCast(u & ~m); } } diff --git a/lib/std/math.zig b/lib/std/math.zig index 3f50e45705dac64a5bf29d78acd01904d459eb5d..6e27df0b21b84ab834a36c5649fd89418848eca7 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -186,9 +186,7 @@ test "approxEqAbs and approxEqRel" { } } -pub fn doNotOptimizeAway(val: anytype) void { - return mem.doNotOptimizeAway(val); -} +pub const doNotOptimizeAway = @compileError("Deprecated: use `std.mem.doNotOptimizeAway` instead"); pub fn raiseInvalid() void { // Raise INVALID fpu exception diff --git a/lib/std/math/asinh.zig b/lib/std/math/asinh.zig index deadcc28850d08a57c4cdad864028d284b84bce0..796be5fdc7a7318c2c947a5ba3fd8330f43fc72b 100644 --- a/lib/std/math/asinh.zig +++ b/lib/std/math/asinh.zig @@ -6,6 +6,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const maxInt = std.math.maxInt; @@ -46,7 +47,7 @@ fn asinh32(x: f32) f32 { } // |x| < 0x1p-12, inexact if x != 0 else { - math.doNotOptimizeAway(rx + 0x1.0p120); + mem.doNotOptimizeAway(rx + 0x1.0p120); } return if (s != 0) -rx else rx; @@ -73,7 +74,7 @@ fn asinh64(x: f64) f64 { } // |x| < 0x1p-12, inexact if x != 0 else { - math.doNotOptimizeAway(rx + 0x1.0p120); + mem.doNotOptimizeAway(rx + 0x1.0p120); } return if (s != 0) -rx else rx; diff --git a/lib/std/math/atan.zig b/lib/std/math/atan.zig index 0e7a86df60b7cb6678f13b073dcce953419c9655..ebd4b8ca5a07b3ab8524f0e859eebe2b68cb0bf6 100644 --- a/lib/std/math/atan.zig +++ b/lib/std/math/atan.zig @@ -6,6 +6,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; /// Returns the arc-tangent of x. @@ -67,7 +68,7 @@ fn atan32(x_: f32) f32 { // |x| < 2^(-12) if (ix < 0x39800000) { if (ix < 0x00800000) { - math.doNotOptimizeAway(x * x); + mem.doNotOptimizeAway(x * x); } return x; } @@ -165,7 +166,7 @@ fn atan64(x_: f64) f64 { // |x| < 2^(-27) if (ix < 0x3E400000) { if (ix < 0x00100000) { - math.doNotOptimizeAway(@as(f32, @floatCast(x))); + mem.doNotOptimizeAway(@as(f32, @floatCast(x))); } return x; } diff --git a/lib/std/math/atanh.zig b/lib/std/math/atanh.zig index 0da2e46ffaf392442754b444b7939ffcff43faa6..3f504bf99f829199703a29baac02caed604f3645 100644 --- a/lib/std/math/atanh.zig +++ b/lib/std/math/atanh.zig @@ -6,6 +6,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const maxInt = std.math.maxInt; @@ -40,7 +41,7 @@ fn atanh_32(x: f32) f32 { if (u < 0x3F800000 - (32 << 23)) { // underflow if (u < (1 << 23)) { - math.doNotOptimizeAway(y * y); + mem.doNotOptimizeAway(y * y); } } // |x| < 0.5 @@ -69,7 +70,7 @@ fn atanh_64(x: f64) f64 { if (e < 0x3FF - 32) { // underflow if (e == 0) { - math.doNotOptimizeAway(@as(f32, @floatCast(y))); + mem.doNotOptimizeAway(@as(f32, @floatCast(y))); } } // |x| < 0.5 diff --git a/lib/std/math/expm1.zig b/lib/std/math/expm1.zig index fc4790410143ca923402fb83664a60f426a6bfcc..e9ba023b922f14ebbaef29c8d771279472e67e78 100644 --- a/lib/std/math/expm1.zig +++ b/lib/std/math/expm1.zig @@ -8,6 +8,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; /// Returns e raised to the power of x, minus 1 (e^x - 1). This is more accurate than exp(e, x) - 1 @@ -100,7 +101,7 @@ fn expm1_32(x_: f32) f32 { // |x| < 2^(-25) else if (hx < 0x33000000) { if (hx < 0x00800000) { - math.doNotOptimizeAway(x * x); + mem.doNotOptimizeAway(x * x); } return x; } else { @@ -231,7 +232,7 @@ fn expm1_64(x_: f64) f64 { // |x| < 2^(-54) else if (hx < 0x3C900000) { if (hx < 0x00100000) { - math.doNotOptimizeAway(@as(f32, @floatCast(x))); + mem.doNotOptimizeAway(@as(f32, @floatCast(x))); } return x; } else { diff --git a/lib/std/math/log1p.zig b/lib/std/math/log1p.zig index 4545823ece6189994328b5266589878376db11d7..0cd34e30bb5295e48253f9b74167256306909488 100644 --- a/lib/std/math/log1p.zig +++ b/lib/std/math/log1p.zig @@ -6,6 +6,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; /// Returns the natural logarithm of 1 + x with greater accuracy when x is near zero. @@ -56,7 +57,7 @@ fn log1p_32(x: f32) f32 { if ((ix << 1) < (0x33800000 << 1)) { // underflow if subnormal if (ix & 0x7F800000 == 0) { - math.doNotOptimizeAway(x * x); + mem.doNotOptimizeAway(x * x); } return x; } diff --git a/lib/std/math/tanh.zig b/lib/std/math/tanh.zig index 41b4bc53872cddce2f61f9872dd92ea62a7a1bf7..f9d023ae41a0106a933d832e378c7520b2b2ba20 100644 --- a/lib/std/math/tanh.zig +++ b/lib/std/math/tanh.zig @@ -6,6 +6,7 @@ const std = @import("../std.zig"); const math = std.math; +const mem = std.mem; const expect = std.testing.expect; const expo2 = @import("expo2.zig").expo2; const maxInt = std.math.maxInt; @@ -58,7 +59,7 @@ fn tanh32(x: f32) f32 { } // |x| is subnormal else { - math.doNotOptimizeAway(ax * ax); + mem.doNotOptimizeAway(ax * ax); t = ax; } @@ -96,7 +97,7 @@ fn tanh64(x: f64) f64 { } // |x| is subnormal else { - math.doNotOptimizeAway(@as(f32, @floatCast(ax))); + mem.doNotOptimizeAway(@as(f32, @floatCast(ax))); t = ax; }