diff --git a/test/behavior/x86_64/binary.zig b/test/behavior/x86_64/binary.zig index a1e827cbb58411013cd95873ff4f8abf713c4322..899092f4058d5a1c1e75c155ec9280a4e11224dc 100644 --- a/test/behavior/x86_64/binary.zig +++ b/test/behavior/x86_64/binary.zig @@ -16,7 +16,6 @@ const nan = math.nan; const Scalar = math.Scalar; const select = math.select; const sign = math.sign; -const splat = math.splat; const Sse = math.Sse; const tmin = math.tmin; @@ -5250,7 +5249,7 @@ test divTruncUnoptimized { inline fn divTruncOptimized(comptime Type: type, lhs: Type, rhs: Type) Type { @setFloatMode(.optimized); - return @divTrunc(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0))); + return @divTrunc(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0)))); } test divTruncOptimized { const test_div_trunc_optimized = binary(divTruncOptimized, .{ .compare = .approx_int }); @@ -5271,7 +5270,7 @@ test divFloorUnoptimized { inline fn divFloorOptimized(comptime Type: type, lhs: Type, rhs: Type) Type { @setFloatMode(.optimized); - return @divFloor(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0))); + return @divFloor(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0)))); } test divFloorOptimized { const test_div_floor_optimized = binary(divFloorOptimized, .{ .compare = .approx_int }); @@ -5292,7 +5291,7 @@ test divCeilUnoptimized { inline fn divCeilOptimized(comptime Type: type, lhs: Type, rhs: Type) Type { @setFloatMode(.optimized); - return @divCeil(lhs, select(@abs(rhs) > splat(Type, 0.0), rhs, splat(Type, 1.0))); + return @divCeil(lhs, select(@abs(rhs) > @as(Type, @splat(0.0)), rhs, @as(Type, @splat(1.0)))); } test divCeilOptimized { const test_div_ceil_optimized = binary(divCeilOptimized, .{ .compare = .approx_int }); @@ -5393,7 +5392,7 @@ test mulWithOverflow { inline fn shlWithOverflow(comptime Type: type, lhs: Type, rhs: Type) struct { Type, ChangeScalar(Type, u1) } { const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); - return @shlWithOverflow(lhs, if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs); + return @shlWithOverflow(lhs, if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs); } test shlWithOverflow { const test_shl_with_overflow = binary(shlWithOverflow, .{}); @@ -5492,7 +5491,7 @@ test bitOr { inline fn shr(comptime Type: type, lhs: Type, rhs: Type) Type { const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); - return lhs >> if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs; + return lhs >> if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs; } test shr { const test_shr = binary(shr, .{}); @@ -5503,7 +5502,7 @@ test shr { inline fn shrExact(comptime Type: type, lhs: Type, rhs: Type) Type { const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); - const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs; + const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs; return @shrExact(lhs >> final_rhs << final_rhs, final_rhs); } test shrExact { @@ -5515,7 +5514,7 @@ test shrExact { inline fn shl(comptime Type: type, lhs: Type, rhs: Type) Type { const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); - return lhs << if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs; + return lhs << if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs; } test shl { const test_shl = binary(shl, .{}); @@ -5527,7 +5526,7 @@ inline fn shlExactUnsafe(comptime Type: type, lhs: Type, rhs: Type) Type { @setRuntimeSafety(false); const bit_cast_rhs: AsSignedness(Type, .unsigned) = @bitCast(rhs); const truncate_rhs: Log2Int(Type) = @truncate(bit_cast_rhs); - const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % splat(Log2Int(Type), bits) else truncate_rhs; + const final_rhs = if (comptime cast(Log2Int(Scalar(Type)), @bitSizeOf(Scalar(Type)))) |bits| truncate_rhs % @as(Log2Int(Type), @splat(bits)) else truncate_rhs; return @shlExact(lhs << final_rhs >> final_rhs, final_rhs); } test shlExactUnsafe { @@ -5540,7 +5539,7 @@ inline fn shlSaturate(comptime Type: type, lhs: Type, rhs: Type) Type { // workaround https://github.com/ziglang/zig/issues/23034 if (@inComptime()) { // workaround https://github.com/ziglang/zig/issues/23139 - return lhs <<| @min(@abs(rhs), splat(ChangeScalar(Type, u64), imax(u64))); + return lhs <<| @min(@abs(rhs), @as(ChangeScalar(Type, u64), @splat(imax(u64)))); } return lhs <<| @abs(rhs); } diff --git a/test/behavior/x86_64/cast.zig b/test/behavior/x86_64/cast.zig index dd538d9c67ee2f4c31d5eb5812190d3a92c3b9d4..35f880fa174f18433529c24dec41ef9cddc2eaca 100644 --- a/test/behavior/x86_64/cast.zig +++ b/test/behavior/x86_64/cast.zig @@ -12,7 +12,6 @@ const math = @import("math.zig"); const nan = math.nan; const next = math.next; const Scalar = math.Scalar; -const splat = math.splat; const Sse = math.Sse; const tmin = math.tmin; @@ -14508,18 +14507,18 @@ inline fn intCast(comptime Result: type, comptime Type: type, rhs: Type, comptim rhs & imax(Type) >> bits, .vector => rhs | @select( Scalar(Type), - ct_rhs < splat(Type, 0), - splat(Type, imin(Scalar(Type)) >> bits), - splat(Type, 0), + ct_rhs < @as(Type, @splat(0)), + @as(Type, @splat(imin(Scalar(Type)) >> bits)), + @as(Type, @splat(0)), ) & ~@select( Scalar(Type), - ct_rhs >= splat(Type, 0), - splat(Type, imin(Scalar(Type)) >> bits), - splat(Type, 0), + ct_rhs >= @as(Type, @splat(0)), + @as(Type, @splat(imin(Scalar(Type)) >> bits)), + @as(Type, @splat(0)), ), else => comptime unreachable, }, - .mask => |bits| if (bits == rhs_info.bits) rhs else rhs & splat(Type, (1 << bits) - 1), + .mask => |bits| if (bits == rhs_info.bits) rhs else rhs & @as(Type, @splat((1 << bits) - 1)), }); } test intCast { diff --git a/test/behavior/x86_64/math.zig b/test/behavior/x86_64/math.zig index 0d5539244b4a0e26b58494733dbea7b3efd4c9a8..f788b31715f757ff390e00bf557ae9bba745c10c 100644 --- a/test/behavior/x86_64/math.zig +++ b/test/behavior/x86_64/math.zig @@ -72,19 +72,13 @@ pub fn Log2Int(comptime Type: type) type { pub fn Log2IntCeil(comptime Type: type) type { return ChangeScalar(Type, math.Log2IntCeil(Scalar(Type))); } -pub fn splat(comptime Type: type, scalar: Scalar(Type)) Type { - return switch (@typeInfo(Type)) { - else => scalar, - .vector => @splat(scalar), - }; -} pub fn sign(rhs: anytype) ChangeScalar(@TypeOf(rhs), bool) { const Int = ChangeScalar(@TypeOf(rhs), switch (@typeInfo(Scalar(@TypeOf(rhs)))) { .int, .comptime_int => Scalar(@TypeOf(rhs)), .float => |float| @Int(.signed, float.bits), else => @compileError(@typeName(@TypeOf(rhs))), }); - return @as(Int, @bitCast(rhs)) < splat(Int, 0); + return @as(Int, @bitCast(rhs)) < @as(Int, @splat(0)); } pub fn select(cond: anytype, lhs: anytype, rhs: @TypeOf(lhs)) @TypeOf(lhs) { return switch (@typeInfo(@TypeOf(cond))) { @@ -117,19 +111,19 @@ pub noinline fn checkExpected(expected: anytype, actual: @TypeOf(expected), comp .approx_or_overflow => @exp2(@log2(epsilon) * 0.4), }; const approx_unequal = @abs(expected - actual) > @max( - @abs(expected) * splat(Expected, tolerance), - splat(Expected, switch (compare) { + @abs(expected) * @as(Expected, @splat(tolerance)), + @as(Expected, @splat(switch (compare) { .strict, .relaxed => comptime unreachable, .approx, .approx_or_overflow => tolerance, .approx_int => 1, - }), + })), ); break :unexpected switch (compare) { .strict, .relaxed => comptime unreachable, .approx, .approx_int => approx_unequal, .approx_or_overflow => approx_unequal & - (((@abs(expected) != splat(Expected, inf(Expected))) & - (@abs(actual) != splat(Expected, inf(Expected)))) | + (((@abs(expected) != @as(Expected, @splat(inf(Expected)))) & + (@abs(actual) != @as(Expected, @splat(inf(Expected))))) | (sign(expected) != sign(actual))), }; },