From 348d1773baec1f9b853827b8318735d9686b699d Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Sun, 9 Feb 2025 00:44:13 -0500 Subject: [PATCH] std: remove special cases for stage2_x86_64 that are no longer needed --- lib/std/Target.zig | 45 ++++++++++++++++++--------------------------- lib/std/math.zig | 2 +- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index 75bad7d585..42267f0ae1 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -1240,13 +1240,10 @@ pub const Cpu = struct { /// Adds the specified feature set but not its dependencies. pub fn addFeatureSet(set: *Set, other_set: Set) void { - switch (builtin.zig_backend) { - .stage2_x86_64 => { - for (&set.ints, other_set.ints) |*set_int, other_set_int| set_int.* |= other_set_int; - }, - else => { - set.ints = @as(@Vector(usize_count, usize), set.ints) | @as(@Vector(usize_count, usize), other_set.ints); - }, + if (builtin.zig_backend == .stage2_x86_64 and builtin.object_format == .coff) { + for (&set.ints, other_set.ints) |*set_int, other_set_int| set_int.* |= other_set_int; + } else { + set.ints = @as(@Vector(usize_count, usize), set.ints) | @as(@Vector(usize_count, usize), other_set.ints); } } @@ -1259,13 +1256,10 @@ pub const Cpu = struct { /// Removes the specified feature but not its dependents. pub fn removeFeatureSet(set: *Set, other_set: Set) void { - switch (builtin.zig_backend) { - .stage2_x86_64 => { - for (&set.ints, other_set.ints) |*set_int, other_set_int| set_int.* &= ~other_set_int; - }, - else => { - set.ints = @as(@Vector(usize_count, usize), set.ints) & ~@as(@Vector(usize_count, usize), other_set.ints); - }, + if (builtin.zig_backend == .stage2_x86_64 and builtin.object_format == .coff) { + for (&set.ints, other_set.ints) |*set_int, other_set_int| set_int.* &= ~other_set_int; + } else { + set.ints = @as(@Vector(usize_count, usize), set.ints) & ~@as(@Vector(usize_count, usize), other_set.ints); } } @@ -1295,19 +1289,16 @@ pub const Cpu = struct { } pub fn isSuperSetOf(set: Set, other_set: Set) bool { - switch (builtin.zig_backend) { - .stage2_x86_64 => { - var result = true; - for (&set.ints, other_set.ints) |*set_int, other_set_int| - result = result and (set_int.* & other_set_int) == other_set_int; - return result; - }, - else => { - const V = @Vector(usize_count, usize); - const set_v: V = set.ints; - const other_v: V = other_set.ints; - return @reduce(.And, (set_v & other_v) == other_v); - }, + if (builtin.zig_backend == .stage2_x86_64 and builtin.object_format == .coff) { + var result = true; + for (&set.ints, other_set.ints) |*set_int, other_set_int| + result = result and (set_int.* & other_set_int) == other_set_int; + return result; + } else { + const V = @Vector(usize_count, usize); + const set_v: V = set.ints; + const other_v: V = other_set.ints; + return @reduce(.And, (set_v & other_v) == other_v); } } }; diff --git a/lib/std/math.zig b/lib/std/math.zig index 1e7858aaa9..262d741e43 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -1356,7 +1356,7 @@ pub fn lerp(a: anytype, b: anytype, t: anytype) @TypeOf(a, b, t) { test lerp { if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/17884 if (builtin.zig_backend == .stage2_x86_64 and - !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .fma)) return error.SkipZigTest; + !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .fma)) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/17884 try testing.expectEqual(@as(f64, 75), lerp(50, 100, 0.5)); try testing.expectEqual(@as(f32, 43.75), lerp(50, 25, 0.25));