mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
x86_64: implement integer @reduce(.Max)
This commit is contained in:
parent
3fd3358f37
commit
8bacf3e757
@ -368,7 +368,8 @@ pub fn countElementsWithValue(vec: anytype, value: std.meta.Child(@TypeOf(vec)))
|
||||
}
|
||||
|
||||
test "vector searching" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and
|
||||
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .ssse3)) return error.SkipZigTest;
|
||||
|
||||
const base = @Vector(8, u32){ 6, 4, 7, 4, 4, 2, 3, 7 };
|
||||
|
||||
|
||||
@ -2142,7 +2142,7 @@ pub const Inst = struct {
|
||||
ref_start_index = static_len,
|
||||
_,
|
||||
|
||||
pub const static_len = 117;
|
||||
pub const static_len = 118;
|
||||
|
||||
pub fn toRef(i: Index) Inst.Ref {
|
||||
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
|
||||
@ -2246,6 +2246,7 @@ pub const Inst = struct {
|
||||
vector_8_u16_type,
|
||||
vector_16_u16_type,
|
||||
vector_32_u16_type,
|
||||
vector_2_i32_type,
|
||||
vector_4_i32_type,
|
||||
vector_8_i32_type,
|
||||
vector_16_i32_type,
|
||||
|
||||
@ -1029,6 +1029,7 @@ pub const Inst = struct {
|
||||
vector_8_u16_type = @intFromEnum(InternPool.Index.vector_8_u16_type),
|
||||
vector_16_u16_type = @intFromEnum(InternPool.Index.vector_16_u16_type),
|
||||
vector_32_u16_type = @intFromEnum(InternPool.Index.vector_32_u16_type),
|
||||
vector_2_i32_type = @intFromEnum(InternPool.Index.vector_2_i32_type),
|
||||
vector_4_i32_type = @intFromEnum(InternPool.Index.vector_4_i32_type),
|
||||
vector_8_i32_type = @intFromEnum(InternPool.Index.vector_8_i32_type),
|
||||
vector_16_i32_type = @intFromEnum(InternPool.Index.vector_16_i32_type),
|
||||
|
||||
@ -4606,6 +4606,7 @@ pub const Index = enum(u32) {
|
||||
vector_8_u16_type,
|
||||
vector_16_u16_type,
|
||||
vector_32_u16_type,
|
||||
vector_2_i32_type,
|
||||
vector_4_i32_type,
|
||||
vector_8_i32_type,
|
||||
vector_16_i32_type,
|
||||
@ -5168,6 +5169,8 @@ pub const static_keys: [static_len]Key = .{
|
||||
.{ .vector_type = .{ .len = 16, .child = .u16_type } },
|
||||
// @Vector(32, u16)
|
||||
.{ .vector_type = .{ .len = 32, .child = .u16_type } },
|
||||
// @Vector(2, i32)
|
||||
.{ .vector_type = .{ .len = 2, .child = .i32_type } },
|
||||
// @Vector(4, i32)
|
||||
.{ .vector_type = .{ .len = 4, .child = .i32_type } },
|
||||
// @Vector(8, i32)
|
||||
@ -11870,6 +11873,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
|
||||
.vector_8_u16_type,
|
||||
.vector_16_u16_type,
|
||||
.vector_32_u16_type,
|
||||
.vector_2_i32_type,
|
||||
.vector_4_i32_type,
|
||||
.vector_8_i32_type,
|
||||
.vector_16_i32_type,
|
||||
@ -12210,6 +12214,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
|
||||
.vector_8_u16_type,
|
||||
.vector_16_u16_type,
|
||||
.vector_32_u16_type,
|
||||
.vector_2_i32_type,
|
||||
.vector_4_i32_type,
|
||||
.vector_8_i32_type,
|
||||
.vector_16_i32_type,
|
||||
|
||||
@ -36562,6 +36562,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
|
||||
.vector_8_u16_type,
|
||||
.vector_16_u16_type,
|
||||
.vector_32_u16_type,
|
||||
.vector_2_i32_type,
|
||||
.vector_4_i32_type,
|
||||
.vector_8_i32_type,
|
||||
.vector_16_i32_type,
|
||||
|
||||
@ -4127,6 +4127,7 @@ pub const vector_4_u16: Type = .{ .ip_index = .vector_4_u16_type };
|
||||
pub const vector_8_u16: Type = .{ .ip_index = .vector_8_u16_type };
|
||||
pub const vector_16_u16: Type = .{ .ip_index = .vector_16_u16_type };
|
||||
pub const vector_32_u16: Type = .{ .ip_index = .vector_32_u16_type };
|
||||
pub const vector_2_i32: Type = .{ .ip_index = .vector_2_i32_type };
|
||||
pub const vector_4_i32: Type = .{ .ip_index = .vector_4_i32_type };
|
||||
pub const vector_8_i32: Type = .{ .ip_index = .vector_8_i32_type };
|
||||
pub const vector_16_i32: Type = .{ .ip_index = .vector_16_i32_type };
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1747,6 +1747,21 @@ pub const Pool = struct {
|
||||
};
|
||||
return pool.fromFields(allocator, .@"struct", &fields, kind);
|
||||
},
|
||||
.vector_2_i32_type => {
|
||||
const vector_ctype = try pool.getVector(allocator, .{
|
||||
.elem_ctype = .i32,
|
||||
.len = 2,
|
||||
});
|
||||
if (!kind.isParameter()) return vector_ctype;
|
||||
var fields = [_]Info.Field{
|
||||
.{
|
||||
.name = .{ .index = .array },
|
||||
.ctype = vector_ctype,
|
||||
.alignas = AlignAs.fromAbiAlignment(Type.i32.abiAlignment(zcu)),
|
||||
},
|
||||
};
|
||||
return pool.fromFields(allocator, .@"struct", &fields, kind);
|
||||
},
|
||||
.vector_4_i32_type => {
|
||||
const vector_ctype = try pool.getVector(allocator, .{
|
||||
.elem_ctype = .i32,
|
||||
|
||||
@ -5102,6 +5102,14 @@ test reduceMin {
|
||||
try test_reduce_min.testIntVectors();
|
||||
}
|
||||
|
||||
inline fn reduceMax(comptime Type: type, rhs: Type) @typeInfo(Type).vector.child {
|
||||
return @reduce(.Max, rhs);
|
||||
}
|
||||
test reduceMax {
|
||||
const test_reduce_max = unary(reduceMax, .{});
|
||||
try test_reduce_max.testIntVectors();
|
||||
}
|
||||
|
||||
inline fn reduceAdd(comptime Type: type, rhs: Type) @typeInfo(Type).vector.child {
|
||||
return @reduce(.Add, rhs);
|
||||
}
|
||||
|
||||
@ -117,9 +117,9 @@ export fn testMutablePointer() void {
|
||||
// tmp.zig:37:38: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type '?u8'
|
||||
// tmp.zig:57:28: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_517'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_518'
|
||||
// tmp.zig:62:39: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_519'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_520'
|
||||
// tmp.zig:67:44: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_522'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_523'
|
||||
// tmp.zig:72:50: note: imported here
|
||||
|
||||
@ -15,6 +15,6 @@ pub export fn entry() void {
|
||||
// error
|
||||
//
|
||||
// :7:25: error: unable to resolve comptime value
|
||||
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_491.C' must be comptime-known
|
||||
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_492.C' must be comptime-known
|
||||
// :4:16: note: struct requires comptime because of this field
|
||||
// :4:16: note: types are not available at runtime
|
||||
|
||||
@ -16,5 +16,5 @@ pub export fn entry2() void {
|
||||
//
|
||||
// :3:6: error: no field or member function named 'copy' in '[]const u8'
|
||||
// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
|
||||
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_495'
|
||||
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_496'
|
||||
// :12:6: note: struct declared here
|
||||
|
||||
@ -6,6 +6,6 @@ export fn foo() void {
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_484'
|
||||
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_485'
|
||||
// :3:16: note: struct declared here
|
||||
// :1:11: note: struct declared here
|
||||
|
||||
@ -44,9 +44,9 @@ comptime {
|
||||
//
|
||||
// :5:23: error: expected error union type, found 'comptime_int'
|
||||
// :10:23: error: expected error union type, found '@TypeOf(.{})'
|
||||
// :15:23: error: expected error union type, found 'tmp.test2__struct_521'
|
||||
// :15:23: error: expected error union type, found 'tmp.test2__struct_522'
|
||||
// :15:23: note: struct declared here
|
||||
// :20:27: error: expected error union type, found 'tmp.test3__struct_523'
|
||||
// :20:27: error: expected error union type, found 'tmp.test3__struct_524'
|
||||
// :20:27: note: struct declared here
|
||||
// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
|
||||
// :31:13: error: expected error union type, found 'u32'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user