From 17e68c4a11ee44dbaf32f5d17abc30aa107a0a2d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 6 Jan 2018 00:15:37 -0500 Subject: [PATCH 1/2] disable NewGVN closes #673 --- src/zig_llvm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp index 94d18b1d49..81e22187ed 100644 --- a/src/zig_llvm.cpp +++ b/src/zig_llvm.cpp @@ -126,7 +126,8 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM PMBuilder->SLPVectorize = !is_debug; PMBuilder->LoopVectorize = !is_debug; PMBuilder->RerollLoops = !is_debug; - PMBuilder->NewGVN = !is_debug; + // Leaving NewGVN as default (off) because when on it caused issue #673 + //PMBuilder->NewGVN = !is_debug; PMBuilder->DisableGVNLoadPRE = is_debug; PMBuilder->VerifyInput = assertions_on; PMBuilder->VerifyOutput = assertions_on; From dde7cc52d2f4780587b37604889c4568b8d79c62 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 6 Jan 2018 02:58:45 -0500 Subject: [PATCH 2/2] fix exp1m implementation in the llvm6 branch with assertions on, it failed the test this fixes it --- std/math/expm1.zig | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/std/math/expm1.zig b/std/math/expm1.zig index 10670c4cfc..f2d4d4f183 100644 --- a/std/math/expm1.zig +++ b/std/math/expm1.zig @@ -4,6 +4,7 @@ // - expm1(-inf) = -1 // - expm1(nan) = nan +const builtin = @import("builtin"); const std = @import("../index.zig"); const math = std.math; const assert = std.debug.assert; @@ -18,6 +19,7 @@ pub fn expm1(x: var) -> @typeOf(x) { } fn expm1_32(x_: f32) -> f32 { + @setFloatMode(this, builtin.FloatMode.Strict); const o_threshold: f32 = 8.8721679688e+01; const ln2_hi: f32 = 6.9313812256e-01; const ln2_lo: f32 = 9.0580006145e-06; @@ -122,7 +124,7 @@ fn expm1_32(x_: f32) -> f32 { } } - const twopk = @bitCast(f32, u32((0x7F + k) << 23)); + const twopk = @bitCast(f32, u32((0x7F +% k) << 23)); if (k < 0 or k > 56) { var y = x - e + 1.0; @@ -135,7 +137,7 @@ fn expm1_32(x_: f32) -> f32 { return y - 1.0; } - const uf = @bitCast(f32, u32(0x7F - k) << 23); + const uf = @bitCast(f32, u32(0x7F -% k) << 23); if (k < 23) { return (x - e + (1 - uf)) * twopk; } else { @@ -144,6 +146,7 @@ fn expm1_32(x_: f32) -> f32 { } fn expm1_64(x_: f64) -> f64 { + @setFloatMode(this, builtin.FloatMode.Strict); const o_threshold: f64 = 7.09782712893383973096e+02; const ln2_hi: f64 = 6.93147180369123816490e-01; const ln2_lo: f64 = 1.90821492927058770002e-10; @@ -251,7 +254,7 @@ fn expm1_64(x_: f64) -> f64 { } } - const twopk = @bitCast(f64, u64(0x3FF + k) << 52); + const twopk = @bitCast(f64, u64(0x3FF +% k) << 52); if (k < 0 or k > 56) { var y = x - e + 1.0; @@ -264,7 +267,7 @@ fn expm1_64(x_: f64) -> f64 { return y - 1.0; } - const uf = @bitCast(f64, u64(0x3FF - k) << 52); + const uf = @bitCast(f64, u64(0x3FF -% k) << 52); if (k < 20) { return (x - e + (1 - uf)) * twopk; } else {