From 55eea3b045c86c78eb8d9cc862122d260352a631 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 14 Oct 2021 21:17:30 -0700 Subject: stage2: implement `@minimum` and `@maximum`, including vectors * std.os: take advantage of `@minimum`. It's probably time to deprecate `std.min` and `std.max`. * New AIR instructions: min and max * Introduce SIMD vector support to stage2 * Add `@Type` support for vectors * Sema: add `checkSimdBinOp` which can be re-used for other arithmatic operators that want to support vectors. * Implement coercion from vectors to arrays. - In backends this is handled with bitcast for vector to array, however maybe we want to reduce the amount of branching by introducing an explicit AIR instruction for it in the future. * LLVM backend: implement lowering vector types * Sema: Implement `slice.ptr` at comptime * Value: improve `numberMin` and `numberMax` to support floats in addition to integers, and make them behave properly in the presence of NaN. --- test/behavior/maximum_minimum.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/behavior/maximum_minimum.zig') diff --git a/test/behavior/maximum_minimum.zig b/test/behavior/maximum_minimum.zig index 5fef818f2b..59a86815aa 100644 --- a/test/behavior/maximum_minimum.zig +++ b/test/behavior/maximum_minimum.zig @@ -8,8 +8,8 @@ const Vector = std.meta.Vector; test "@maximum" { const S = struct { fn doTheTest() !void { - try expectEqual(@as(i32, 10), @maximum(@as(i32, -3), @as(i32, 10))); - try expectEqual(@as(f32, 3.2), @maximum(@as(f32, 3.2), @as(f32, 0.68))); + try expect(@as(i32, 10) == @maximum(@as(i32, -3), @as(i32, 10))); + try expect(@as(f32, 3.2) == @maximum(@as(f32, 3.2), @as(f32, 0.68))); var a: Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var b: Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; @@ -34,8 +34,8 @@ test "@maximum" { test "@minimum" { const S = struct { fn doTheTest() !void { - try expectEqual(@as(i32, -3), @minimum(@as(i32, -3), @as(i32, 10))); - try expectEqual(@as(f32, 0.68), @minimum(@as(f32, 3.2), @as(f32, 0.68))); + try expect(@as(i32, -3) == @minimum(@as(i32, -3), @as(i32, 10))); + try expect(@as(f32, 0.68) == @minimum(@as(f32, 3.2), @as(f32, 0.68))); var a: Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 }; var b: Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 }; -- cgit v1.2.3