aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/vector.zig1
-rw-r--r--test/behavior/x86_64/mem.zig26
2 files changed, 25 insertions, 2 deletions
diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig
index 497a3df310..818fbcd7e4 100644
--- a/test/behavior/vector.zig
+++ b/test/behavior/vector.zig
@@ -1391,7 +1391,6 @@ test "store packed vector element" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
if (builtin.cpu.arch == .aarch64_be and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
diff --git a/test/behavior/x86_64/mem.zig b/test/behavior/x86_64/mem.zig
index 139e3a1471..5c6cbe0301 100644
--- a/test/behavior/x86_64/mem.zig
+++ b/test/behavior/x86_64/mem.zig
@@ -1,3 +1,7 @@
+const math = @import("math.zig");
+const imax = math.imax;
+const imin = math.imin;
+
fn accessSlice(comptime array: anytype) !void {
var slice: []const @typeInfo(@TypeOf(array)).array.child = undefined;
slice = &array;
@@ -38,13 +42,33 @@ test accessSlice {
fn accessVector(comptime init: anytype) !void {
const Vector = @TypeOf(init);
+ const Elem = @typeInfo(Vector).vector.child;
+ const ct_vals: [2]Elem = switch (Elem) {
+ bool => .{ false, true },
+ else => .{ imin(Elem), imax(Elem) },
+ };
+ var rt_vals: [2]Elem = undefined;
+ rt_vals = ct_vals;
var vector: Vector = undefined;
vector = init;
inline for (0..@typeInfo(Vector).vector.len) |ct_index| {
var rt_index: usize = undefined;
rt_index = ct_index;
if (&vector[rt_index] != &vector[ct_index]) return error.Unexpected;
- if (vector[rt_index] != vector[ct_index]) return error.Unexpected;
+ if (vector[rt_index] != init[ct_index]) return error.Unexpected;
+ if (vector[ct_index] != init[ct_index]) return error.Unexpected;
+ vector[rt_index] = rt_vals[0];
+ if (vector[rt_index] != ct_vals[0]) return error.Unexpected;
+ if (vector[ct_index] != ct_vals[0]) return error.Unexpected;
+ vector[rt_index] = ct_vals[1];
+ if (vector[rt_index] != ct_vals[1]) return error.Unexpected;
+ if (vector[ct_index] != ct_vals[1]) return error.Unexpected;
+ vector[ct_index] = ct_vals[0];
+ if (vector[rt_index] != ct_vals[0]) return error.Unexpected;
+ if (vector[ct_index] != ct_vals[0]) return error.Unexpected;
+ vector[ct_index] = rt_vals[1];
+ if (vector[rt_index] != ct_vals[1]) return error.Unexpected;
+ if (vector[ct_index] != ct_vals[1]) return error.Unexpected;
}
}
test accessVector {