authorgravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-10-20 17:31:54-07:00
committergravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-10-21 02:17:59-07:00
logbd2db84eede87bf2336a624ff21e798e8b631921
treea3c425ef6a1b48035865c4b6249b6e5e1534b1c4
parente572063f92ddd497c5bb6a067358bdbae1c16aab

Remove no longer necessary `splat` helper from x86_64 backend tests


3 files changed, 22 insertions(+), 30 deletions(-)

test/behavior/x86_64/binary.zig+9-10
......@@ -16,7 +16,6 @@ const nan = math.nan;
1616const Scalar = math.Scalar;
1717const select = math.select;
1818const sign = math.sign;
19const splat = math.splat;
2019const Sse = math.Sse;
2120const tmin = math.tmin;
2221
......@@ -5250,7 +5249,7 @@ test divTruncUnoptimized {
52505249
52515250inline fn divTruncOptimized(comptime Type: type, lhs: Type, rhs: Type) Type {
52525251 @setFloatMode(.optimized);
5253 return @divTrunc(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0)));
5252 return @divTrunc(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0))));
52545253}
52555254test divTruncOptimized {
52565255 const test_div_trunc_optimized = binary(divTruncOptimized, .{ .compare = .approx_int });
......@@ -5271,7 +5270,7 @@ test divFloorUnoptimized {
52715270
52725271inline fn divFloorOptimized(comptime Type: type, lhs: Type, rhs: Type) Type {
52735272 @setFloatMode(.optimized);
5274 return @divFloor(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0)));
5273 return @divFloor(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0))));
52755274}
52765275test divFloorOptimized {
52775276 const test_div_floor_optimized = binary(divFloorOptimized, .{ .compare = .approx_int });
......@@ -5292,7 +5291,7 @@ test divCeilUnoptimized {
52925291
52935292inline fn divCeilOptimized(comptime Type: type, lhs: Type, rhs: Type) Type {
52945293 @setFloatMode(.optimized);
5295 return @divCeil(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0)));
5294 return @divCeil(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0))));
52965295}
52975296test divCeilOptimized {
52985297 const test_div_ceil_optimized = binary(divCeilOptimized, .{ .compare = .approx_int });
......@@ -5393,7 +5392,7 @@ test mulWithOverflow {
53935392inline fn shlWithOverflow(comptime Type: type, lhs: Type, rhs: Type) struct { Type, ChangeScalar(Type, u1) } {
53945393 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
53955394 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5396 return @shlWithOverflow(lhs, if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs);
5395 return @shlWithOverflow(lhs, if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs);
53975396}
53985397test shlWithOverflow {
53995398 const test_shl_with_overflow = binary(shlWithOverflow, .{});
......@@ -5492,7 +5491,7 @@ test bitOr {
54925491inline fn shr(comptime Type: type, lhs: Type, rhs: Type) Type {
54935492 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
54945493 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5495 return lhs >> if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs;
5494 return lhs >> if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
54965495}
54975496test shr {
54985497 const test_shr = binary(shr, .{});
......@@ -5503,7 +5502,7 @@ test shr {
55035502inline fn shrExact(comptime Type: type, lhs: Type, rhs: Type) Type {
55045503 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
55055504 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5506 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs;
5505 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
55075506 return @shrExact(lhs >> final_rhs << final_rhs, final_rhs);
55085507}
55095508test shrExact {
......@@ -5515,7 +5514,7 @@ test shrExact {
55155514inline fn shl(comptime Type: type, lhs: Type, rhs: Type) Type {
55165515 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
55175516 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5518 return lhs << if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs;
5517 return lhs << if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
55195518}
55205519test shl {
55215520 const test_shl = binary(shl, .{});
......@@ -5527,7 +5526,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type {
55275526 @setRuntimeSafety(false);
55285527 const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs);
55295528 const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs);
5530 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs;
5529 const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs;
55315530 return @shlExact(lhs << final_rhs >> final_rhs, final_rhs);
55325531}
55335532test shlExactUnsafe {
......@@ -5540,7 +5539,7 @@ inline fn shlSaturate(comptime Type: type, lhs: Type, rhs: Type) Type {
55405539 // workaround https://github.com/ziglang/zig/issues/23034
55415540 if (@inComptime()) {
55425541 // workaround https://github.com/ziglang/zig/issues/23139
5543 return lhs <<| @min(@abs(rhs), splat(ChangeScalar(Type, u64), imax(u64)));
5542 return lhs <<| @min(@abs(rhs), @as(ChangeScalar(Type, u64), @splat(imax(u64))));
55445543 }
55455544 return lhs <<| @abs(rhs);
55465545}
test/behavior/x86_64/cast.zig+7-8
......@@ -12,7 +12,6 @@ const math = @import("math.zig");
1212const nan = math.nan;
1313const next = math.next;
1414const Scalar = math.Scalar;
15const splat = math.splat;
1615const Sse = math.Sse;
1716const tmin = math.tmin;
1817
......@@ -14508,18 +14507,18 @@ inline fn intCast(comptime Result: type, comptime Type: type, rhs: Type, comptim
1450814507 rhs & imax(Type) >> bits,
1450914508 .vector => rhs | @select(
1451014509 Scalar(Type),
14511 ct_rhs < splat(Type, 0),
14512 splat(Type, imin(Scalar(Type)) >> bits),
14513 splat(Type, 0),
14510 ct_rhs < @as(Type, @splat(0)),
14511 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
14512 @as(Type, @splat(0)),
1451414513 ) & ~@select(
1451514514 Scalar(Type),
14516 ct_rhs >= splat(Type, 0),
14517 splat(Type, imin(Scalar(Type)) >> bits),
14518 splat(Type, 0),
14515 ct_rhs >= @as(Type, @splat(0)),
14516 @as(Type, @splat(imin(Scalar(Type)) >> bits)),
14517 @as(Type, @splat(0)),
1451914518 ),
1452014519 else => comptime unreachable,
1452114520 },
14522 .mask => |bits| if (bits == rhs_info.bits) rhs else rhs & splat(Type, (1 << bits) - 1),
14521 .mask => |bits| if (bits == rhs_info.bits) rhs else rhs & @as(Type, @splat((1 << bits) - 1)),
1452314522 });
1452414523}
1452514524test intCast {
test/behavior/x86_64/math.zig+6-12
......@@ -72,19 +72,13 @@ pub fn Log2Int(comptime Type: type) type {
7272pub fn Log2IntCeil(comptime Type: type) type {
7373 return ChangeScalar(Type, math.Log2IntCeil(Scalar(Type)));
7474}
75pub fn splat(comptime Type: type, scalar: Scalar(Type)) Type {
76 return switch (@typeInfo(Type)) {
77 else => scalar,
78 .vector => @splat(scalar),
79 };
80}
8175pub fn sign(rhs: anytype) ChangeScalar(@TypeOf(rhs), bool) {
8276 const Int = ChangeScalar(@TypeOf(rhs), switch (@typeInfo(Scalar(@TypeOf(rhs)))) {
8377 .int, .comptime_int => Scalar(@TypeOf(rhs)),
8478 .float => |float| @Int(.signed, float.bits),
8579 else => @compileError(@typeName(@TypeOf(rhs))),
8680 });
87 return @as(Int, @bitCast(rhs)) < splat(Int, 0);
81 return @as(Int, @bitCast(rhs)) < @as(Int, @splat(0));
8882}
8983pub fn select(cond: anytype, lhs: anytype, rhs: @TypeOf(lhs)) @TypeOf(lhs) {
9084 return switch (@typeInfo(@TypeOf(cond))) {
......@@ -117,19 +111,19 @@ pub noinline fn checkExpected(expected: anytype, actual: @TypeOf(expected), comp
117111 .approx_or_overflow => @exp2(@log2(epsilon) * 0.4),
118112 };
119113 const approx_unequal = @abs(expected - actual) > @max(
120 @abs(expected) * splat(Expected, tolerance),
121 splat(Expected, switch (compare) {
114 @abs(expected) * @as(Expected, @splat(tolerance)),
115 @as(Expected, @splat(switch (compare) {
122116 .strict, .relaxed => comptime unreachable,
123117 .approx, .approx_or_overflow => tolerance,
124118 .approx_int => 1,
125 }),
119 })),
126120 );
127121 break :unexpected switch (compare) {
128122 .strict, .relaxed => comptime unreachable,
129123 .approx, .approx_int => approx_unequal,
130124 .approx_or_overflow => approx_unequal &
131 (((@abs(expected) != splat(Expected, inf(Expected))) &
132 (@abs(actual) != splat(Expected, inf(Expected)))) |
125 (((@abs(expected) != @as(Expected, @splat(inf(Expected)))) &
126 (@abs(actual) != @as(Expected, @splat(inf(Expected))))) |
133127 (sign(expected) != sign(actual))),
134128 };
135129 },