| author | |
| committer | |
| log | 54f4abae2f811c6de1d5c5156961e1bd75405aa6 |
| tree | 924e25ffeecbeaa82331b2f9a43b7c14ff457fdc |
| parent | 464ce8ac67eb0ef15cc535d2b10394343dd44a2c |
| signature |
17 files changed, 59 insertions(+), 45 deletions(-)
lib/compiler_rt/ceil.zig+5-4| ... | @@ -8,6 +8,7 @@ const std = @import("std"); | ... | @@ -8,6 +8,7 @@ const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| 13 | 14 | ||
| ... | @@ -47,14 +48,14 @@ pub fn ceilf(x: f32) callconv(.C) f32 { | ... | @@ -47,14 +48,14 @@ pub fn ceilf(x: f32) callconv(.C) f32 { |
| 47 | if (u & m == 0) { | 48 | if (u & m == 0) { |
| 48 | return x; | 49 | return x; |
| 49 | } | 50 | } |
| 50 | math.doNotOptimizeAway(x + 0x1.0p120); | 51 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 51 | if (u >> 31 == 0) { | 52 | if (u >> 31 == 0) { |
| 52 | u += m; | 53 | u += m; |
| 53 | } | 54 | } |
| 54 | u &= ~m; | 55 | u &= ~m; |
| 55 | return @bitCast(u); | 56 | return @bitCast(u); |
| 56 | } else { | 57 | } else { |
| 57 | math.doNotOptimizeAway(x + 0x1.0p120); | 58 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 58 | if (u >> 31 != 0) { | 59 | if (u >> 31 != 0) { |
| 59 | return -0.0; | 60 | return -0.0; |
| 60 | } else { | 61 | } else { |
| ... | @@ -81,7 +82,7 @@ pub fn ceil(x: f64) callconv(.C) f64 { | ... | @@ -81,7 +82,7 @@ pub fn ceil(x: f64) callconv(.C) f64 { |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | if (e <= 0x3FF - 1) { | 84 | if (e <= 0x3FF - 1) { |
| 84 | math.doNotOptimizeAway(y); | 85 | mem.doNotOptimizeAway(y); |
| 85 | if (u >> 63 != 0) { | 86 | if (u >> 63 != 0) { |
| 86 | return -0.0; | 87 | return -0.0; |
| 87 | } else { | 88 | } else { |
| ... | @@ -115,7 +116,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 { | ... | @@ -115,7 +116,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 { |
| 115 | } | 116 | } |
| 116 | 117 | ||
| 117 | if (e <= 0x3FFF - 1) { | 118 | if (e <= 0x3FFF - 1) { |
| 118 | math.doNotOptimizeAway(y); | 119 | mem.doNotOptimizeAway(y); |
| 119 | if (u >> 127 != 0) { | 120 | if (u >> 127 != 0) { |
| 120 | return -0.0; | 121 | return -0.0; |
| 121 | } else { | 122 | } else { |
lib/compiler_rt/cos.zig+3-2| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const math = std.math; | 2 | const math = std.math; |
| 3 | const mem = std.mem; | ||
| 3 | const expect = std.testing.expect; | 4 | const expect = std.testing.expect; |
| 4 | const common = @import("common.zig"); | 5 | const common = @import("common.zig"); |
| 5 | 6 | ||
| ... | @@ -40,7 +41,7 @@ pub fn cosf(x: f32) callconv(.C) f32 { | ... | @@ -40,7 +41,7 @@ pub fn cosf(x: f32) callconv(.C) f32 { |
| 40 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 | 41 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 |
| 41 | if (ix < 0x39800000) { // |x| < 2**-12 | 42 | if (ix < 0x39800000) { // |x| < 2**-12 |
| 42 | // raise inexact if x != 0 | 43 | // raise inexact if x != 0 |
| 43 | math.doNotOptimizeAway(x + 0x1p120); | 44 | mem.doNotOptimizeAway(x + 0x1p120); |
| 44 | return 1.0; | 45 | return 1.0; |
| 45 | } | 46 | } |
| 46 | return trig.__cosdf(x); | 47 | return trig.__cosdf(x); |
| ... | @@ -91,7 +92,7 @@ pub fn cos(x: f64) callconv(.C) f64 { | ... | @@ -91,7 +92,7 @@ pub fn cos(x: f64) callconv(.C) f64 { |
| 91 | if (ix <= 0x3fe921fb) { | 92 | if (ix <= 0x3fe921fb) { |
| 92 | if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2) | 93 | if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2) |
| 93 | // raise inexact if x!=0 | 94 | // raise inexact if x!=0 |
| 94 | math.doNotOptimizeAway(x + 0x1p120); | 95 | mem.doNotOptimizeAway(x + 0x1p120); |
| 95 | return 1.0; | 96 | return 1.0; |
| 96 | } | 97 | } |
| 97 | return trig.__cos(x, 0); | 98 | return trig.__cos(x, 0); |
lib/compiler_rt/exp.zig+5-4| ... | @@ -8,6 +8,7 @@ const std = @import("std"); | ... | @@ -8,6 +8,7 @@ const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| 13 | 14 | ||
| ... | @@ -58,7 +59,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { | ... | @@ -58,7 +59,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { |
| 58 | return x * 0x1.0p127; | 59 | return x * 0x1.0p127; |
| 59 | } | 60 | } |
| 60 | if (sign != 0) { | 61 | if (sign != 0) { |
| 61 | math.doNotOptimizeAway(-0x1.0p-149 / x); // overflow | 62 | mem.doNotOptimizeAway(-0x1.0p-149 / x); // overflow |
| 62 | // x <= -103.972084 | 63 | // x <= -103.972084 |
| 63 | if (hx >= 0x42CFF1B5) { | 64 | if (hx >= 0x42CFF1B5) { |
| 64 | return 0; | 65 | return 0; |
| ... | @@ -90,7 +91,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { | ... | @@ -90,7 +91,7 @@ pub fn expf(x_: f32) callconv(.C) f32 { |
| 90 | hi = x; | 91 | hi = x; |
| 91 | lo = 0; | 92 | lo = 0; |
| 92 | } else { | 93 | } else { |
| 93 | math.doNotOptimizeAway(0x1.0p127 + x); // inexact | 94 | mem.doNotOptimizeAway(0x1.0p127 + x); // inexact |
| 94 | return 1 + x; | 95 | return 1 + x; |
| 95 | } | 96 | } |
| 96 | 97 | ||
| ... | @@ -141,7 +142,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { | ... | @@ -141,7 +142,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { |
| 141 | } | 142 | } |
| 142 | if (x < -708.39641853226410622) { | 143 | if (x < -708.39641853226410622) { |
| 143 | // underflow if x != -inf | 144 | // underflow if x != -inf |
| 144 | // math.doNotOptimizeAway(@as(f32, -0x1.0p-149 / x)); | 145 | // mem.doNotOptimizeAway(@as(f32, -0x1.0p-149 / x)); |
| 145 | if (x < -745.13321910194110842) { | 146 | if (x < -745.13321910194110842) { |
| 146 | return 0; | 147 | return 0; |
| 147 | } | 148 | } |
| ... | @@ -174,7 +175,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { | ... | @@ -174,7 +175,7 @@ pub fn exp(x_: f64) callconv(.C) f64 { |
| 174 | lo = 0; | 175 | lo = 0; |
| 175 | } else { | 176 | } else { |
| 176 | // inexact if x != 0 | 177 | // inexact if x != 0 |
| 177 | // math.doNotOptimizeAway(0x1.0p1023 + x); | 178 | // mem.doNotOptimizeAway(0x1.0p1023 + x); |
| 178 | return 1 + x; | 179 | return 1 + x; |
| 179 | } | 180 | } |
| 180 | 181 |
lib/compiler_rt/exp2.zig+3-2| ... | @@ -8,6 +8,7 @@ const std = @import("std"); | ... | @@ -8,6 +8,7 @@ const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| 13 | 14 | ||
| ... | @@ -54,7 +55,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 { | ... | @@ -54,7 +55,7 @@ pub fn exp2f(x: f32) callconv(.C) f32 { |
| 54 | // x < -126 | 55 | // x < -126 |
| 55 | if (u >= 0x80000000) { | 56 | if (u >= 0x80000000) { |
| 56 | if (u >= 0xC3160000 or u & 0x000FFFF != 0) { | 57 | if (u >= 0xC3160000 or u & 0x000FFFF != 0) { |
| 57 | math.doNotOptimizeAway(-0x1.0p-149 / x); | 58 | mem.doNotOptimizeAway(-0x1.0p-149 / x); |
| 58 | } | 59 | } |
| 59 | // x <= -150 | 60 | // x <= -150 |
| 60 | if (u >= 0x3160000) { | 61 | if (u >= 0x3160000) { |
| ... | @@ -119,7 +120,7 @@ pub fn exp2(x: f64) callconv(.C) f64 { | ... | @@ -119,7 +120,7 @@ pub fn exp2(x: f64) callconv(.C) f64 { |
| 119 | if (ux >> 63 != 0) { | 120 | if (ux >> 63 != 0) { |
| 120 | // underflow | 121 | // underflow |
| 121 | if (x <= -1075 or x - 0x1.0p52 + 0x1.0p52 != x) { | 122 | if (x <= -1075 or x - 0x1.0p52 + 0x1.0p52 != x) { |
| 122 | math.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); | 123 | mem.doNotOptimizeAway(@as(f32, @floatCast(-0x1.0p-149 / x))); |
| 123 | } | 124 | } |
| 124 | if (x <= -1075) { | 125 | if (x <= -1075) { |
| 125 | return 0; | 126 | return 0; |
lib/compiler_rt/floor.zig+7-6| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const mem = std.mem; | ||
| 10 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | 12 | const arch = builtin.cpu.arch; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| ... | @@ -44,13 +45,13 @@ pub fn __floorh(x: f16) callconv(.C) f16 { | ... | @@ -44,13 +45,13 @@ pub fn __floorh(x: f16) callconv(.C) f16 { |
| 44 | if (u & m == 0) { | 45 | if (u & m == 0) { |
| 45 | return x; | 46 | return x; |
| 46 | } | 47 | } |
| 47 | math.doNotOptimizeAway(x + 0x1.0p120); | 48 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 48 | if (u >> 15 != 0) { | 49 | if (u >> 15 != 0) { |
| 49 | u += m; | 50 | u += m; |
| 50 | } | 51 | } |
| 51 | return @bitCast(u & ~m); | 52 | return @bitCast(u & ~m); |
| 52 | } else { | 53 | } else { |
| 53 | math.doNotOptimizeAway(x + 0x1.0p120); | 54 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 54 | if (u >> 15 == 0) { | 55 | if (u >> 15 == 0) { |
| 55 | return 0.0; | 56 | return 0.0; |
| 56 | } else { | 57 | } else { |
| ... | @@ -78,13 +79,13 @@ pub fn floorf(x: f32) callconv(.C) f32 { | ... | @@ -78,13 +79,13 @@ pub fn floorf(x: f32) callconv(.C) f32 { |
| 78 | if (u & m == 0) { | 79 | if (u & m == 0) { |
| 79 | return x; | 80 | return x; |
| 80 | } | 81 | } |
| 81 | math.doNotOptimizeAway(x + 0x1.0p120); | 82 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 82 | if (u >> 31 != 0) { | 83 | if (u >> 31 != 0) { |
| 83 | u += m; | 84 | u += m; |
| 84 | } | 85 | } |
| 85 | return @bitCast(u & ~m); | 86 | return @bitCast(u & ~m); |
| 86 | } else { | 87 | } else { |
| 87 | math.doNotOptimizeAway(x + 0x1.0p120); | 88 | mem.doNotOptimizeAway(x + 0x1.0p120); |
| 88 | if (u >> 31 == 0) { | 89 | if (u >> 31 == 0) { |
| 89 | return 0.0; | 90 | return 0.0; |
| 90 | } else { | 91 | } else { |
| ... | @@ -111,7 +112,7 @@ pub fn floor(x: f64) callconv(.C) f64 { | ... | @@ -111,7 +112,7 @@ pub fn floor(x: f64) callconv(.C) f64 { |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | if (e <= 0x3FF - 1) { | 114 | if (e <= 0x3FF - 1) { |
| 114 | math.doNotOptimizeAway(y); | 115 | mem.doNotOptimizeAway(y); |
| 115 | if (u >> 63 != 0) { | 116 | if (u >> 63 != 0) { |
| 116 | return -1.0; | 117 | return -1.0; |
| 117 | } else { | 118 | } else { |
| ... | @@ -145,7 +146,7 @@ pub fn floorq(x: f128) callconv(.C) f128 { | ... | @@ -145,7 +146,7 @@ pub fn floorq(x: f128) callconv(.C) f128 { |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | if (e <= 0x3FFF - 1) { | 148 | if (e <= 0x3FFF - 1) { |
| 148 | math.doNotOptimizeAway(y); | 149 | mem.doNotOptimizeAway(y); |
| 149 | if (u >> 127 != 0) { | 150 | if (u >> 127 != 0) { |
| 150 | return -1.0; | 151 | return -1.0; |
| 151 | } else { | 152 | } else { |
lib/compiler_rt/round.zig+4-3| ... | @@ -7,6 +7,7 @@ | ... | @@ -7,6 +7,7 @@ |
| 7 | const std = @import("std"); | 7 | const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const math = std.math; | 9 | const math = std.math; |
| 10 | const mem = std.mem; | ||
| 10 | const expect = std.testing.expect; | 11 | const expect = std.testing.expect; |
| 11 | const arch = builtin.cpu.arch; | 12 | const arch = builtin.cpu.arch; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| ... | @@ -45,7 +46,7 @@ pub fn roundf(x_: f32) callconv(.C) f32 { | ... | @@ -45,7 +46,7 @@ pub fn roundf(x_: f32) callconv(.C) f32 { |
| 45 | x = -x; | 46 | x = -x; |
| 46 | } | 47 | } |
| 47 | if (e < 0x7F - 1) { | 48 | if (e < 0x7F - 1) { |
| 48 | math.doNotOptimizeAway(x + f32_toint); | 49 | mem.doNotOptimizeAway(x + f32_toint); |
| 49 | return 0 * @as(f32, @bitCast(u)); | 50 | return 0 * @as(f32, @bitCast(u)); |
| 50 | } | 51 | } |
| 51 | 52 | ||
| ... | @@ -80,7 +81,7 @@ pub fn round(x_: f64) callconv(.C) f64 { | ... | @@ -80,7 +81,7 @@ pub fn round(x_: f64) callconv(.C) f64 { |
| 80 | x = -x; | 81 | x = -x; |
| 81 | } | 82 | } |
| 82 | if (e < 0x3ff - 1) { | 83 | if (e < 0x3ff - 1) { |
| 83 | math.doNotOptimizeAway(x + f64_toint); | 84 | mem.doNotOptimizeAway(x + f64_toint); |
| 84 | return 0 * @as(f64, @bitCast(u)); | 85 | return 0 * @as(f64, @bitCast(u)); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| ... | @@ -120,7 +121,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 { | ... | @@ -120,7 +121,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 { |
| 120 | x = -x; | 121 | x = -x; |
| 121 | } | 122 | } |
| 122 | if (e < 0x3FFF - 1) { | 123 | if (e < 0x3FFF - 1) { |
| 123 | math.doNotOptimizeAway(x + f128_toint); | 124 | mem.doNotOptimizeAway(x + f128_toint); |
| 124 | return 0 * @as(f128, @bitCast(u)); | 125 | return 0 * @as(f128, @bitCast(u)); |
| 125 | } | 126 | } |
| 126 | 127 |
lib/compiler_rt/sin.zig+3-2| ... | @@ -8,6 +8,7 @@ const std = @import("std"); | ... | @@ -8,6 +8,7 @@ const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| 13 | 14 | ||
| ... | @@ -48,7 +49,7 @@ pub fn sinf(x: f32) callconv(.C) f32 { | ... | @@ -48,7 +49,7 @@ pub fn sinf(x: f32) callconv(.C) f32 { |
| 48 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 | 49 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 |
| 49 | if (ix < 0x39800000) { // |x| < 2**-12 | 50 | if (ix < 0x39800000) { // |x| < 2**-12 |
| 50 | // raise inexact if x!=0 and underflow if subnormal | 51 | // raise inexact if x!=0 and underflow if subnormal |
| 51 | math.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); | 52 | mem.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); |
| 52 | return x; | 53 | return x; |
| 53 | } | 54 | } |
| 54 | return trig.__sindf(x); | 55 | return trig.__sindf(x); |
| ... | @@ -97,7 +98,7 @@ pub fn sin(x: f64) callconv(.C) f64 { | ... | @@ -97,7 +98,7 @@ pub fn sin(x: f64) callconv(.C) f64 { |
| 97 | if (ix <= 0x3fe921fb) { | 98 | if (ix <= 0x3fe921fb) { |
| 98 | if (ix < 0x3e500000) { // |x| < 2**-26 | 99 | if (ix < 0x3e500000) { // |x| < 2**-26 |
| 99 | // raise inexact if x != 0 and underflow if subnormal | 100 | // raise inexact if x != 0 and underflow if subnormal |
| 100 | math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); | 101 | mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); |
| 101 | return x; | 102 | return x; |
| 102 | } | 103 | } |
| 103 | return trig.__sin(x, 0.0, 0); | 104 | return trig.__sin(x, 0.0, 0); |
lib/compiler_rt/sincos.zig+4-3| ... | @@ -2,6 +2,7 @@ const std = @import("std"); | ... | @@ -2,6 +2,7 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const arch = builtin.cpu.arch; | 3 | const arch = builtin.cpu.arch; |
| 4 | const math = std.math; | 4 | const math = std.math; |
| 5 | const mem = std.mem; | ||
| 5 | const trig = @import("trig.zig"); | 6 | const trig = @import("trig.zig"); |
| 6 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; | 7 | const rem_pio2 = @import("rem_pio2.zig").rem_pio2; |
| 7 | const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f; | 8 | 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 { | ... | @@ -45,7 +46,7 @@ pub fn sincosf(x: f32, r_sin: *f32, r_cos: *f32) callconv(.C) void { |
| 45 | // |x| < 2**-12 | 46 | // |x| < 2**-12 |
| 46 | if (ix < 0x39800000) { | 47 | if (ix < 0x39800000) { |
| 47 | // raise inexact if x!=0 and underflow if subnormal | 48 | // raise inexact if x!=0 and underflow if subnormal |
| 48 | math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); | 49 | mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); |
| 49 | r_sin.* = x; | 50 | r_sin.* = x; |
| 50 | r_cos.* = 1.0; | 51 | r_cos.* = 1.0; |
| 51 | return; | 52 | return; |
| ... | @@ -133,7 +134,7 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.C) void { | ... | @@ -133,7 +134,7 @@ pub fn sincos(x: f64, r_sin: *f64, r_cos: *f64) callconv(.C) void { |
| 133 | // if |x| < 2**-27 * sqrt(2) | 134 | // if |x| < 2**-27 * sqrt(2) |
| 134 | if (ix < 0x3e46a09e) { | 135 | if (ix < 0x3e46a09e) { |
| 135 | // raise inexact if x != 0 and underflow if subnormal | 136 | // raise inexact if x != 0 and underflow if subnormal |
| 136 | math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); | 137 | mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); |
| 137 | r_sin.* = x; | 138 | r_sin.* = x; |
| 138 | r_cos.* = 1.0; | 139 | r_cos.* = 1.0; |
| 139 | return; | 140 | return; |
| ... | @@ -231,7 +232,7 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { | ... | @@ -231,7 +232,7 @@ inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void { |
| 231 | if (se < 0x3fff - math.floatFractionalBits(F) - 1) { | 232 | if (se < 0x3fff - math.floatFractionalBits(F) - 1) { |
| 232 | // raise underflow if subnormal | 233 | // raise underflow if subnormal |
| 233 | if (se == 0) { | 234 | if (se == 0) { |
| 234 | math.doNotOptimizeAway(x * 0x1p-120); | 235 | mem.doNotOptimizeAway(x * 0x1p-120); |
| 235 | } | 236 | } |
| 236 | r_sin.* = x; | 237 | r_sin.* = x; |
| 237 | // raise inexact if x!=0 | 238 | // raise inexact if x!=0 |
lib/compiler_rt/tan.zig+3-2| ... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
| 8 | const std = @import("std"); | 8 | const std = @import("std"); |
| 9 | const builtin = @import("builtin"); | 9 | const builtin = @import("builtin"); |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | 13 | ||
| 13 | const kernel = @import("trig.zig"); | 14 | const kernel = @import("trig.zig"); |
| ... | @@ -50,7 +51,7 @@ pub fn tanf(x: f32) callconv(.C) f32 { | ... | @@ -50,7 +51,7 @@ pub fn tanf(x: f32) callconv(.C) f32 { |
| 50 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 | 51 | if (ix <= 0x3f490fda) { // |x| ~<= pi/4 |
| 51 | if (ix < 0x39800000) { // |x| < 2**-12 | 52 | if (ix < 0x39800000) { // |x| < 2**-12 |
| 52 | // raise inexact if x!=0 and underflow if subnormal | 53 | // raise inexact if x!=0 and underflow if subnormal |
| 53 | math.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); | 54 | mem.doNotOptimizeAway(if (ix < 0x00800000) x / 0x1p120 else x + 0x1p120); |
| 54 | return x; | 55 | return x; |
| 55 | } | 56 | } |
| 56 | return kernel.__tandf(x, false); | 57 | return kernel.__tandf(x, false); |
| ... | @@ -88,7 +89,7 @@ pub fn tan(x: f64) callconv(.C) f64 { | ... | @@ -88,7 +89,7 @@ pub fn tan(x: f64) callconv(.C) f64 { |
| 88 | if (ix <= 0x3fe921fb) { | 89 | if (ix <= 0x3fe921fb) { |
| 89 | if (ix < 0x3e400000) { // |x| < 2**-27 | 90 | if (ix < 0x3e400000) { // |x| < 2**-27 |
| 90 | // raise inexact if x!=0 and underflow if subnormal | 91 | // raise inexact if x!=0 and underflow if subnormal |
| 91 | math.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); | 92 | mem.doNotOptimizeAway(if (ix < 0x00100000) x / 0x1p120 else x + 0x1p120); |
| 92 | return x; | 93 | return x; |
| 93 | } | 94 | } |
| 94 | return kernel.__tan(x, 0.0, false); | 95 | return kernel.__tan(x, 0.0, false); |
lib/compiler_rt/trunc.zig+4-3| ... | @@ -8,6 +8,7 @@ const std = @import("std"); | ... | @@ -8,6 +8,7 @@ const std = @import("std"); |
| 8 | const builtin = @import("builtin"); | 8 | const builtin = @import("builtin"); |
| 9 | const arch = builtin.cpu.arch; | 9 | const arch = builtin.cpu.arch; |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | const common = @import("common.zig"); | 13 | const common = @import("common.zig"); |
| 13 | 14 | ||
| ... | @@ -46,7 +47,7 @@ pub fn truncf(x: f32) callconv(.C) f32 { | ... | @@ -46,7 +47,7 @@ pub fn truncf(x: f32) callconv(.C) f32 { |
| 46 | if (u & m == 0) { | 47 | if (u & m == 0) { |
| 47 | return x; | 48 | return x; |
| 48 | } else { | 49 | } else { |
| 49 | math.doNotOptimizeAway(x + 0x1p120); | 50 | mem.doNotOptimizeAway(x + 0x1p120); |
| 50 | return @bitCast(u & ~m); | 51 | return @bitCast(u & ~m); |
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| ... | @@ -67,7 +68,7 @@ pub fn trunc(x: f64) callconv(.C) f64 { | ... | @@ -67,7 +68,7 @@ pub fn trunc(x: f64) callconv(.C) f64 { |
| 67 | if (u & m == 0) { | 68 | if (u & m == 0) { |
| 68 | return x; | 69 | return x; |
| 69 | } else { | 70 | } else { |
| 70 | math.doNotOptimizeAway(x + 0x1p120); | 71 | mem.doNotOptimizeAway(x + 0x1p120); |
| 71 | return @bitCast(u & ~m); | 72 | return @bitCast(u & ~m); |
| 72 | } | 73 | } |
| 73 | } | 74 | } |
| ... | @@ -93,7 +94,7 @@ pub fn truncq(x: f128) callconv(.C) f128 { | ... | @@ -93,7 +94,7 @@ pub fn truncq(x: f128) callconv(.C) f128 { |
| 93 | if (u & m == 0) { | 94 | if (u & m == 0) { |
| 94 | return x; | 95 | return x; |
| 95 | } else { | 96 | } else { |
| 96 | math.doNotOptimizeAway(x + 0x1p120); | 97 | mem.doNotOptimizeAway(x + 0x1p120); |
| 97 | return @bitCast(u & ~m); | 98 | return @bitCast(u & ~m); |
| 98 | } | 99 | } |
| 99 | } | 100 | } |
lib/std/math.zig+1-3| ... | @@ -186,9 +186,7 @@ test "approxEqAbs and approxEqRel" { | ... | @@ -186,9 +186,7 @@ test "approxEqAbs and approxEqRel" { |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | pub fn doNotOptimizeAway(val: anytype) void { | 189 | pub const doNotOptimizeAway = @compileError("Deprecated: use `std.mem.doNotOptimizeAway` instead"); |
| 190 | return mem.doNotOptimizeAway(val); | ||
| 191 | } | ||
| 192 | 190 | ||
| 193 | pub fn raiseInvalid() void { | 191 | pub fn raiseInvalid() void { |
| 194 | // Raise INVALID fpu exception | 192 | // Raise INVALID fpu exception |
lib/std/math/asinh.zig+3-2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | const mem = std.mem; | ||
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 11 | 12 | ||
| ... | @@ -46,7 +47,7 @@ fn asinh32(x: f32) f32 { | ... | @@ -46,7 +47,7 @@ fn asinh32(x: f32) f32 { |
| 46 | } | 47 | } |
| 47 | // |x| < 0x1p-12, inexact if x != 0 | 48 | // |x| < 0x1p-12, inexact if x != 0 |
| 48 | else { | 49 | else { |
| 49 | math.doNotOptimizeAway(rx + 0x1.0p120); | 50 | mem.doNotOptimizeAway(rx + 0x1.0p120); |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | return if (s != 0) -rx else rx; | 53 | return if (s != 0) -rx else rx; |
| ... | @@ -73,7 +74,7 @@ fn asinh64(x: f64) f64 { | ... | @@ -73,7 +74,7 @@ fn asinh64(x: f64) f64 { |
| 73 | } | 74 | } |
| 74 | // |x| < 0x1p-12, inexact if x != 0 | 75 | // |x| < 0x1p-12, inexact if x != 0 |
| 75 | else { | 76 | else { |
| 76 | math.doNotOptimizeAway(rx + 0x1.0p120); | 77 | mem.doNotOptimizeAway(rx + 0x1.0p120); |
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | return if (s != 0) -rx else rx; | 80 | return if (s != 0) -rx else rx; |
lib/std/math/atan.zig+3-2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | const mem = std.mem; | ||
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | 11 | ||
| 11 | /// Returns the arc-tangent of x. | 12 | /// Returns the arc-tangent of x. |
| ... | @@ -67,7 +68,7 @@ fn atan32(x_: f32) f32 { | ... | @@ -67,7 +68,7 @@ fn atan32(x_: f32) f32 { |
| 67 | // |x| < 2^(-12) | 68 | // |x| < 2^(-12) |
| 68 | if (ix < 0x39800000) { | 69 | if (ix < 0x39800000) { |
| 69 | if (ix < 0x00800000) { | 70 | if (ix < 0x00800000) { |
| 70 | math.doNotOptimizeAway(x * x); | 71 | mem.doNotOptimizeAway(x * x); |
| 71 | } | 72 | } |
| 72 | return x; | 73 | return x; |
| 73 | } | 74 | } |
| ... | @@ -165,7 +166,7 @@ fn atan64(x_: f64) f64 { | ... | @@ -165,7 +166,7 @@ fn atan64(x_: f64) f64 { |
| 165 | // |x| < 2^(-27) | 166 | // |x| < 2^(-27) |
| 166 | if (ix < 0x3E400000) { | 167 | if (ix < 0x3E400000) { |
| 167 | if (ix < 0x00100000) { | 168 | if (ix < 0x00100000) { |
| 168 | math.doNotOptimizeAway(@as(f32, @floatCast(x))); | 169 | mem.doNotOptimizeAway(@as(f32, @floatCast(x))); |
| 169 | } | 170 | } |
| 170 | return x; | 171 | return x; |
| 171 | } | 172 | } |
lib/std/math/atanh.zig+3-2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | const mem = std.mem; | ||
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | const maxInt = std.math.maxInt; | 11 | const maxInt = std.math.maxInt; |
| 11 | 12 | ||
| ... | @@ -40,7 +41,7 @@ fn atanh_32(x: f32) f32 { | ... | @@ -40,7 +41,7 @@ fn atanh_32(x: f32) f32 { |
| 40 | if (u < 0x3F800000 - (32 << 23)) { | 41 | if (u < 0x3F800000 - (32 << 23)) { |
| 41 | // underflow | 42 | // underflow |
| 42 | if (u < (1 << 23)) { | 43 | if (u < (1 << 23)) { |
| 43 | math.doNotOptimizeAway(y * y); | 44 | mem.doNotOptimizeAway(y * y); |
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| 46 | // |x| < 0.5 | 47 | // |x| < 0.5 |
| ... | @@ -69,7 +70,7 @@ fn atanh_64(x: f64) f64 { | ... | @@ -69,7 +70,7 @@ fn atanh_64(x: f64) f64 { |
| 69 | if (e < 0x3FF - 32) { | 70 | if (e < 0x3FF - 32) { |
| 70 | // underflow | 71 | // underflow |
| 71 | if (e == 0) { | 72 | if (e == 0) { |
| 72 | math.doNotOptimizeAway(@as(f32, @floatCast(y))); | 73 | mem.doNotOptimizeAway(@as(f32, @floatCast(y))); |
| 73 | } | 74 | } |
| 74 | } | 75 | } |
| 75 | // |x| < 0.5 | 76 | // |x| < 0.5 |
lib/std/math/expm1.zig+3-2| ... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | ||
| 9 | const std = @import("../std.zig"); | 9 | const std = @import("../std.zig"); |
| 10 | const math = std.math; | 10 | const math = std.math; |
| 11 | const mem = std.mem; | ||
| 11 | const expect = std.testing.expect; | 12 | const expect = std.testing.expect; |
| 12 | 13 | ||
| 13 | /// Returns e raised to the power of x, minus 1 (e^x - 1). This is more accurate than exp(e, x) - 1 | 14 | /// 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 { | ... | @@ -100,7 +101,7 @@ fn expm1_32(x_: f32) f32 { |
| 100 | // |x| < 2^(-25) | 101 | // |x| < 2^(-25) |
| 101 | else if (hx < 0x33000000) { | 102 | else if (hx < 0x33000000) { |
| 102 | if (hx < 0x00800000) { | 103 | if (hx < 0x00800000) { |
| 103 | math.doNotOptimizeAway(x * x); | 104 | mem.doNotOptimizeAway(x * x); |
| 104 | } | 105 | } |
| 105 | return x; | 106 | return x; |
| 106 | } else { | 107 | } else { |
| ... | @@ -231,7 +232,7 @@ fn expm1_64(x_: f64) f64 { | ... | @@ -231,7 +232,7 @@ fn expm1_64(x_: f64) f64 { |
| 231 | // |x| < 2^(-54) | 232 | // |x| < 2^(-54) |
| 232 | else if (hx < 0x3C900000) { | 233 | else if (hx < 0x3C900000) { |
| 233 | if (hx < 0x00100000) { | 234 | if (hx < 0x00100000) { |
| 234 | math.doNotOptimizeAway(@as(f32, @floatCast(x))); | 235 | mem.doNotOptimizeAway(@as(f32, @floatCast(x))); |
| 235 | } | 236 | } |
| 236 | return x; | 237 | return x; |
| 237 | } else { | 238 | } else { |
lib/std/math/log1p.zig+2-1| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | const mem = std.mem; | ||
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | 11 | ||
| 11 | /// Returns the natural logarithm of 1 + x with greater accuracy when x is near zero. | 12 | /// 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 { | ... | @@ -56,7 +57,7 @@ fn log1p_32(x: f32) f32 { |
| 56 | if ((ix << 1) < (0x33800000 << 1)) { | 57 | if ((ix << 1) < (0x33800000 << 1)) { |
| 57 | // underflow if subnormal | 58 | // underflow if subnormal |
| 58 | if (ix & 0x7F800000 == 0) { | 59 | if (ix & 0x7F800000 == 0) { |
| 59 | math.doNotOptimizeAway(x * x); | 60 | mem.doNotOptimizeAway(x * x); |
| 60 | } | 61 | } |
| 61 | return x; | 62 | return x; |
| 62 | } | 63 | } |
lib/std/math/tanh.zig+3-2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | const std = @import("../std.zig"); | 7 | const std = @import("../std.zig"); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | const mem = std.mem; | ||
| 9 | const expect = std.testing.expect; | 10 | const expect = std.testing.expect; |
| 10 | const expo2 = @import("expo2.zig").expo2; | 11 | const expo2 = @import("expo2.zig").expo2; |
| 11 | const maxInt = std.math.maxInt; | 12 | const maxInt = std.math.maxInt; |
| ... | @@ -58,7 +59,7 @@ fn tanh32(x: f32) f32 { | ... | @@ -58,7 +59,7 @@ fn tanh32(x: f32) f32 { |
| 58 | } | 59 | } |
| 59 | // |x| is subnormal | 60 | // |x| is subnormal |
| 60 | else { | 61 | else { |
| 61 | math.doNotOptimizeAway(ax * ax); | 62 | mem.doNotOptimizeAway(ax * ax); |
| 62 | t = ax; | 63 | t = ax; |
| 63 | } | 64 | } |
| 64 | 65 | ||
| ... | @@ -96,7 +97,7 @@ fn tanh64(x: f64) f64 { | ... | @@ -96,7 +97,7 @@ fn tanh64(x: f64) f64 { |
| 96 | } | 97 | } |
| 97 | // |x| is subnormal | 98 | // |x| is subnormal |
| 98 | else { | 99 | else { |
| 99 | math.doNotOptimizeAway(@as(f32, @floatCast(ax))); | 100 | mem.doNotOptimizeAway(@as(f32, @floatCast(ax))); |
| 100 | t = ax; | 101 | t = ax; |
| 101 | } | 102 | } |
| 102 | 103 |