aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/select.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-03-11 16:11:09 -0400
committerGitHub <noreply@github.com>2025-03-11 16:11:09 -0400
commit982c500be5285500a236ca01c2f66e8555647a52 (patch)
tree070417adb81d973df463dd7f4adb40d175af453f /test/behavior/select.zig
parentf66067546775a04ca0cda1c74cb9002d02dc49d5 (diff)
parentcff90e3ae0b14da5163ea0c3283557f402001c67 (diff)
downloadzig-982c500be5285500a236ca01c2f66e8555647a52.tar.gz
zig-982c500be5285500a236ca01c2f66e8555647a52.zip
Merge pull request #23188 from jacobly0/fix-23143
x86_64: fix crashes with symbols
Diffstat (limited to 'test/behavior/select.zig')
-rw-r--r--test/behavior/select.zig20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/behavior/select.zig b/test/behavior/select.zig
index f551ff9533..604227b17f 100644
--- a/test/behavior/select.zig
+++ b/test/behavior/select.zig
@@ -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();
+}