Skip to content

Commit 71d0d4b

Browse files
committed
test: separate out float vector tests and skip them on unsupported backends
1 parent 981f841 commit 71d0d4b

File tree

1 file changed

+90
-5
lines changed

1 file changed

+90
-5
lines changed

test/behavior/floatop.zig

Lines changed: 90 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,19 @@ test "cmp f16" {
132132
try comptime testCmp(f16);
133133
}
134134

135-
test "cmp f32/f64" {
135+
test "cmp f32" {
136136
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
137-
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
138137
if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
139138

140139
try testCmp(f32);
141140
try comptime testCmp(f32);
141+
}
142+
143+
test "cmp f64" {
144+
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
145+
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
146+
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
147+
142148
try testCmp(f64);
143149
try comptime testCmp(f64);
144150
}
@@ -194,7 +200,7 @@ fn testCmp(comptime T: type) !void {
194200
try expect(x <= 2.0);
195201
}
196202

197-
@setEvalBranchQuota(4_000);
203+
@setEvalBranchQuota(2_000);
198204
var edges = [_]T{
199205
-math.inf(T),
200206
-math.floatMax(T),
@@ -210,7 +216,6 @@ fn testCmp(comptime T: type) !void {
210216
};
211217
_ = &edges;
212218
for (edges, 0..) |rhs, rhs_i| {
213-
const rhs_v: @Vector(4, T) = @splat(rhs);
214219
for (edges, 0..) |lhs, lhs_i| {
215220
const no_nan = lhs_i != 5 and rhs_i != 5;
216221
const lhs_order = if (lhs_i < 5) lhs_i else lhs_i - 2;
@@ -221,8 +226,88 @@ fn testCmp(comptime T: type) !void {
221226
try expect((lhs > rhs) == (no_nan and lhs_order > rhs_order));
222227
try expect((lhs <= rhs) == (no_nan and lhs_order <= rhs_order));
223228
try expect((lhs >= rhs) == (no_nan and lhs_order >= rhs_order));
229+
}
230+
}
231+
}
232+
233+
test "vector cmp f16" {
234+
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
235+
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
236+
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
237+
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
238+
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
239+
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
240+
241+
try testCmpVector(f16);
242+
try comptime testCmpVector(f16);
243+
}
244+
245+
test "vector cmp f32" {
246+
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
247+
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
248+
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
249+
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
250+
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
251+
252+
try testCmpVector(f32);
253+
try comptime testCmpVector(f32);
254+
}
255+
256+
test "vector cmp f64" {
257+
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
258+
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
259+
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
260+
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
261+
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
262+
263+
try testCmpVector(f64);
264+
try comptime testCmpVector(f64);
265+
}
266+
267+
test "vector cmp f128" {
268+
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
269+
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
270+
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
271+
if (builtin.zig_backend == .stage2_c and builtin.cpu.arch.isArm()) return error.SkipZigTest;
272+
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
273+
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
274+
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
275+
276+
try testCmpVector(f128);
277+
try comptime testCmpVector(f128);
278+
}
224279

225-
const lhs_v: @Vector(4, T) = @splat(lhs);
280+
test "vector cmp f80/c_longdouble" {
281+
if (true) return error.SkipZigTest;
282+
283+
try testCmpVector(f80);
284+
try comptime testCmpVector(f80);
285+
try testCmpVector(c_longdouble);
286+
try comptime testCmpVector(c_longdouble);
287+
}
288+
fn testCmpVector(comptime T: type) !void {
289+
@setEvalBranchQuota(4_000);
290+
var edges = [_]T{
291+
-math.inf(T),
292+
-math.floatMax(T),
293+
-math.floatMin(T),
294+
-math.floatTrueMin(T),
295+
-0.0,
296+
math.nan(T),
297+
0.0,
298+
math.floatTrueMin(T),
299+
math.floatMin(T),
300+
math.floatMax(T),
301+
math.inf(T),
302+
};
303+
_ = &edges;
304+
for (edges, 0..) |rhs, rhs_i| {
305+
const rhs_v: @Vector(4, T) = .{ rhs, rhs, rhs, rhs };
306+
for (edges, 0..) |lhs, lhs_i| {
307+
const no_nan = lhs_i != 5 and rhs_i != 5;
308+
const lhs_order = if (lhs_i < 5) lhs_i else lhs_i - 2;
309+
const rhs_order = if (rhs_i < 5) rhs_i else rhs_i - 2;
310+
const lhs_v: @Vector(4, T) = .{ lhs, lhs, lhs, lhs };
226311
try expect(@reduce(.And, (lhs_v == rhs_v)) == (no_nan and lhs_order == rhs_order));
227312
try expect(@reduce(.And, (lhs_v != rhs_v)) == !(no_nan and lhs_order == rhs_order));
228313
try expect(@reduce(.And, (lhs_v < rhs_v)) == (no_nan and lhs_order < rhs_order));

0 commit comments

Comments
 (0)