diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-08-18 02:22:40 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-09-19 09:37:52 -0700 |
| commit | d65318847ff4f8eb9d6655b27bf769ea94c2c3d7 (patch) | |
| tree | e048c9b992e0703ae1007a7bc634ea176da6b65b | |
| parent | 821971106383e6e64e679c4402278399798c76eb (diff) | |
| download | zig-d65318847ff4f8eb9d6655b27bf769ea94c2c3d7.tar.gz zig-d65318847ff4f8eb9d6655b27bf769ea94c2c3d7.zip | |
compiler_rt: fix fp sub being optimized to call itself
Closes #16844
Reduces #16846
| -rw-r--r-- | lib/compiler_rt/subdf3.zig | 10 | ||||
| -rw-r--r-- | lib/compiler_rt/subhf3.zig | 3 | ||||
| -rw-r--r-- | lib/compiler_rt/subsf3.zig | 10 | ||||
| -rw-r--r-- | lib/compiler_rt/subtf3.zig | 3 | ||||
| -rw-r--r-- | test/behavior/atomics.zig | 5 | ||||
| -rw-r--r-- | test/behavior/floatop.zig | 40 | ||||
| -rw-r--r-- | test/behavior/math.zig | 28 | ||||
| -rw-r--r-- | test/behavior/muladd.zig | 28 | ||||
| -rw-r--r-- | test/behavior/vector.zig | 7 |
9 files changed, 18 insertions, 116 deletions
diff --git a/lib/compiler_rt/subdf3.zig b/lib/compiler_rt/subdf3.zig index 31e3447298..a67eb9de57 100644 --- a/lib/compiler_rt/subdf3.zig +++ b/lib/compiler_rt/subdf3.zig @@ -1,4 +1,5 @@ const common = @import("./common.zig"); +const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; @@ -11,11 +12,14 @@ comptime { } fn __subdf3(a: f64, b: f64) callconv(.C) f64 { - const neg_b = @as(f64, @bitCast(@as(u64, @bitCast(b)) ^ (@as(u64, 1) << 63))); - return a + neg_b; + return sub(a, b); } fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 { + return sub(a, b); +} + +inline fn sub(a: f64, b: f64) f64 { const neg_b = @as(f64, @bitCast(@as(u64, @bitCast(b)) ^ (@as(u64, 1) << 63))); - return a + neg_b; + return addf3(f64, a, neg_b); } diff --git a/lib/compiler_rt/subhf3.zig b/lib/compiler_rt/subhf3.zig index 5f84f32725..51602851b2 100644 --- a/lib/compiler_rt/subhf3.zig +++ b/lib/compiler_rt/subhf3.zig @@ -1,4 +1,5 @@ const common = @import("./common.zig"); +const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; @@ -8,5 +9,5 @@ comptime { fn __subhf3(a: f16, b: f16) callconv(.C) f16 { const neg_b = @as(f16, @bitCast(@as(u16, @bitCast(b)) ^ (@as(u16, 1) << 15))); - return a + neg_b; + return addf3(f16, a, neg_b); } diff --git a/lib/compiler_rt/subsf3.zig b/lib/compiler_rt/subsf3.zig index f94d9802d1..40c7a44ddd 100644 --- a/lib/compiler_rt/subsf3.zig +++ b/lib/compiler_rt/subsf3.zig @@ -1,4 +1,5 @@ const common = @import("./common.zig"); +const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; @@ -11,11 +12,14 @@ comptime { } fn __subsf3(a: f32, b: f32) callconv(.C) f32 { - const neg_b = @as(f32, @bitCast(@as(u32, @bitCast(b)) ^ (@as(u32, 1) << 31))); - return a + neg_b; + return sub(a, b); } fn __aeabi_fsub(a: f32, b: f32) callconv(.AAPCS) f32 { + return sub(a, b); +} + +inline fn sub(a: f32, b: f32) f32 { const neg_b = @as(f32, @bitCast(@as(u32, @bitCast(b)) ^ (@as(u32, 1) << 31))); - return a + neg_b; + return addf3(f32, a, neg_b); } diff --git a/lib/compiler_rt/subtf3.zig b/lib/compiler_rt/subtf3.zig index ee6383a07d..bda7cb0e31 100644 --- a/lib/compiler_rt/subtf3.zig +++ b/lib/compiler_rt/subtf3.zig @@ -1,4 +1,5 @@ const common = @import("./common.zig"); +const addf3 = @import("./addf3.zig").addf3; pub const panic = common.panic; @@ -21,5 +22,5 @@ fn _Qp_sub(c: *f128, a: *const f128, b: *const f128) callconv(.C) void { inline fn sub(a: f128, b: f128) f128 { const neg_b = @as(f128, @bitCast(@as(u128, @bitCast(b)) ^ (@as(u128, 1) << 127))); - return a + neg_b; + return addf3(f128, a, neg_b); } diff --git a/test/behavior/atomics.zig b/test/behavior/atomics.zig index 158c931eb6..5264ef75cf 100644 --- a/test/behavior/atomics.zig +++ b/test/behavior/atomics.zig @@ -243,11 +243,6 @@ test "atomicrmw with ints" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isMIPS()) { - // https://github.com/ziglang/zig/issues/16846 - return error.SkipZigTest; - } - try testAtomicRmwInts(); try comptime testAtomicRmwInts(); } diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 4a6023b6cc..3583a67701 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -711,18 +711,6 @@ test "@floor f80" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isMIPS()) { - // https://github.com/ziglang/zig/issues/16846 - return error.SkipZigTest; - } - try testFloorLegacy(f80, 12.0); try comptime testFloorLegacy(f80, 12.0); } @@ -734,13 +722,6 @@ test "@floor f128" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch.isARM()) { // https://github.com/ziglang/zig/issues/16848 return error.SkipZigTest; @@ -831,13 +812,6 @@ test "@ceil f80" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try testCeilLegacy(f80, 12.0); try comptime testCeilLegacy(f80, 12.0); } @@ -849,13 +823,6 @@ test "@ceil f128" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try testCeilLegacy(f128, 12.0); try comptime testCeilLegacy(f128, 12.0); } @@ -962,13 +929,6 @@ test "@trunc f128" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try testTruncLegacy(f128, 12.0); try comptime testTruncLegacy(f128, 12.0); } diff --git a/test/behavior/math.zig b/test/behavior/math.zig index ddc9978c45..a7aea59e9a 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -1360,13 +1360,6 @@ test "float remainder division using @rem" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime frem(f16); try comptime frem(f32); try comptime frem(f64); @@ -1410,13 +1403,6 @@ test "float modulo division using @mod" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime fmod(f16); try comptime fmod(f32); try comptime fmod(f64); @@ -1480,13 +1466,6 @@ test "@round f80" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try testRound(f80, 12.0); try comptime testRound(f80, 12.0); } @@ -1499,13 +1478,6 @@ test "@round f128" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try testRound(f128, 12.0); try comptime testRound(f128, 12.0); } diff --git a/test/behavior/muladd.zig b/test/behavior/muladd.zig index 1d8f6104ad..f9caea3a75 100644 --- a/test/behavior/muladd.zig +++ b/test/behavior/muladd.zig @@ -62,13 +62,6 @@ test "@mulAdd f80" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime testMulAdd80(); try testMulAdd80(); } @@ -93,13 +86,6 @@ test "@mulAdd f128" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime testMulAdd128(); try testMulAdd128(); } @@ -203,13 +189,6 @@ test "vector f80" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime vector80(); try vector80(); } @@ -235,13 +214,6 @@ test "vector f128" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - try comptime vector128(); try vector128(); } diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index 7316d69e56..0b95caa0d3 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -104,13 +104,6 @@ test "vector float operators" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and - (builtin.cpu.arch == .powerpc64le or builtin.cpu.arch == .aarch64)) - { - // https://github.com/ziglang/zig/issues/16844 - return error.SkipZigTest; - } - inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { const S = struct { fn doTheTest() !void { |
