Merge pull request #23188 from jacobly0/fix-23143

x86_64: fix crashes with symbols
This commit is contained in:
Andrew Kelley
2025-03-11 16:11:09 -04:00
committed by GitHub
3 changed files with 212 additions and 71 deletions

View File

@@ -66,3 +66,23 @@ fn selectArrays() !void {
const xyz = @select(f32, x, y, z);
try expect(mem.eql(f32, &@as([4]f32, xyz), &[4]f32{ 0.0, 312.1, -145.9, -3381.233 }));
}
test "@select compare result" {
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
const S = struct {
fn min(comptime V: type, lhs: V, rhs: V) V {
return @select(@typeInfo(V).vector.child, lhs < rhs, lhs, rhs);
}
fn doTheTest() !void {
try expect(@reduce(.And, min(@Vector(4, f32), .{ -1, 2, -3, 4 }, .{ 1, -2, 3, -4 }) == @Vector(4, f32){ -1, -2, -3, -4 }));
try expect(@reduce(.And, min(@Vector(2, f64), .{ -1, 2 }, .{ 1, -2 }) == @Vector(2, f64){ -1, -2 }));
}
};
try S.doTheTest();
try comptime S.doTheTest();
}