Skip to content

Commit 19a0db4

Browse files
committed
x86_64: rewrite bitwise @reduce
1 parent a63f787 commit 19a0db4

16 files changed

+10320
-1511
lines changed

lib/std/crypto/timing_safe.zig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ test eql {
192192
}
193193

194194
test "eql (vectors)" {
195-
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
196-
197195
const random = std.crypto.random;
198196
const expect = std.testing.expect;
199197
var a: [100]u8 = undefined;

lib/std/zig/Zir.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ pub const Inst = struct {
21422142
ref_start_index = static_len,
21432143
_,
21442144

2145-
pub const static_len = 101;
2145+
pub const static_len = 105;
21462146

21472147
pub fn toRef(i: Index) Inst.Ref {
21482148
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
@@ -2190,6 +2190,7 @@ pub const Inst = struct {
21902190
u80_type,
21912191
u128_type,
21922192
i128_type,
2193+
u256_type,
21932194
usize_type,
21942195
isize_type,
21952196
c_char_type,
@@ -2234,6 +2235,7 @@ pub const Inst = struct {
22342235
vector_8_u8_type,
22352236
vector_16_u8_type,
22362237
vector_32_u8_type,
2238+
vector_64_u8_type,
22372239
vector_4_i16_type,
22382240
vector_8_i16_type,
22392241
vector_16_i16_type,
@@ -2248,7 +2250,9 @@ pub const Inst = struct {
22482250
vector_4_i64_type,
22492251
vector_2_u64_type,
22502252
vector_4_u64_type,
2253+
vector_1_u128_type,
22512254
vector_2_u128_type,
2255+
vector_1_u256_type,
22522256
vector_4_f16_type,
22532257
vector_8_f16_type,
22542258
vector_2_f32_type,

src/Air.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ pub const Inst = struct {
962962
u80_type = @intFromEnum(InternPool.Index.u80_type),
963963
u128_type = @intFromEnum(InternPool.Index.u128_type),
964964
i128_type = @intFromEnum(InternPool.Index.i128_type),
965+
u256_type = @intFromEnum(InternPool.Index.u256_type),
965966
usize_type = @intFromEnum(InternPool.Index.usize_type),
966967
isize_type = @intFromEnum(InternPool.Index.isize_type),
967968
c_char_type = @intFromEnum(InternPool.Index.c_char_type),
@@ -1006,6 +1007,7 @@ pub const Inst = struct {
10061007
vector_8_u8_type = @intFromEnum(InternPool.Index.vector_8_u8_type),
10071008
vector_16_u8_type = @intFromEnum(InternPool.Index.vector_16_u8_type),
10081009
vector_32_u8_type = @intFromEnum(InternPool.Index.vector_32_u8_type),
1010+
vector_64_u8_type = @intFromEnum(InternPool.Index.vector_64_u8_type),
10091011
vector_4_i16_type = @intFromEnum(InternPool.Index.vector_4_i16_type),
10101012
vector_8_i16_type = @intFromEnum(InternPool.Index.vector_8_i16_type),
10111013
vector_16_i16_type = @intFromEnum(InternPool.Index.vector_16_i16_type),
@@ -1020,7 +1022,9 @@ pub const Inst = struct {
10201022
vector_4_i64_type = @intFromEnum(InternPool.Index.vector_4_i64_type),
10211023
vector_2_u64_type = @intFromEnum(InternPool.Index.vector_2_u64_type),
10221024
vector_4_u64_type = @intFromEnum(InternPool.Index.vector_4_u64_type),
1025+
vector_1_u128_type = @intFromEnum(InternPool.Index.vector_1_u128_type),
10231026
vector_2_u128_type = @intFromEnum(InternPool.Index.vector_2_u128_type),
1027+
vector_1_u256_type = @intFromEnum(InternPool.Index.vector_1_u256_type),
10241028
vector_4_f16_type = @intFromEnum(InternPool.Index.vector_4_f16_type),
10251029
vector_8_f16_type = @intFromEnum(InternPool.Index.vector_8_f16_type),
10261030
vector_2_f32_type = @intFromEnum(InternPool.Index.vector_2_f32_type),

src/InternPool.zig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,6 +4548,7 @@ pub const Index = enum(u32) {
45484548
u80_type,
45494549
u128_type,
45504550
i128_type,
4551+
u256_type,
45514552
usize_type,
45524553
isize_type,
45534554
c_char_type,
@@ -4594,6 +4595,7 @@ pub const Index = enum(u32) {
45944595
vector_8_u8_type,
45954596
vector_16_u8_type,
45964597
vector_32_u8_type,
4598+
vector_64_u8_type,
45974599
vector_4_i16_type,
45984600
vector_8_i16_type,
45994601
vector_16_i16_type,
@@ -4608,7 +4610,9 @@ pub const Index = enum(u32) {
46084610
vector_4_i64_type,
46094611
vector_2_u64_type,
46104612
vector_4_u64_type,
4613+
vector_1_u128_type,
46114614
vector_2_u128_type,
4615+
vector_1_u256_type,
46124616
vector_4_f16_type,
46134617
vector_8_f16_type,
46144618
vector_2_f32_type,
@@ -5022,6 +5026,11 @@ pub const static_keys = [_]Key{
50225026
.bits = 128,
50235027
} },
50245028

5029+
.{ .int_type = .{
5030+
.signedness = .unsigned,
5031+
.bits = 256,
5032+
} },
5033+
50255034
.{ .simple_type = .usize },
50265035
.{ .simple_type = .isize },
50275036
.{ .simple_type = .c_char },
@@ -5125,6 +5134,8 @@ pub const static_keys = [_]Key{
51255134
.{ .vector_type = .{ .len = 16, .child = .u8_type } },
51265135
// @Vector(32, u8)
51275136
.{ .vector_type = .{ .len = 32, .child = .u8_type } },
5137+
// @Vector(64, u8)
5138+
.{ .vector_type = .{ .len = 64, .child = .u8_type } },
51285139
// @Vector(4, i16)
51295140
.{ .vector_type = .{ .len = 4, .child = .i16_type } },
51305141
// @Vector(8, i16)
@@ -5153,8 +5164,12 @@ pub const static_keys = [_]Key{
51535164
.{ .vector_type = .{ .len = 2, .child = .u64_type } },
51545165
// @Vector(8, u64)
51555166
.{ .vector_type = .{ .len = 4, .child = .u64_type } },
5167+
// @Vector(1, u128)
5168+
.{ .vector_type = .{ .len = 1, .child = .u128_type } },
51565169
// @Vector(2, u128)
51575170
.{ .vector_type = .{ .len = 2, .child = .u128_type } },
5171+
// @Vector(1, u256)
5172+
.{ .vector_type = .{ .len = 1, .child = .u256_type } },
51585173
// @Vector(4, f16)
51595174
.{ .vector_type = .{ .len = 4, .child = .f16_type } },
51605175
// @Vector(8, f16)
@@ -11767,6 +11782,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1176711782
.u80_type,
1176811783
.u128_type,
1176911784
.i128_type,
11785+
.u256_type,
1177011786
.usize_type,
1177111787
.isize_type,
1177211788
.c_char_type,
@@ -11811,6 +11827,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1181111827
.vector_8_u8_type,
1181211828
.vector_16_u8_type,
1181311829
.vector_32_u8_type,
11830+
.vector_64_u8_type,
1181411831
.vector_4_i16_type,
1181511832
.vector_8_i16_type,
1181611833
.vector_16_i16_type,
@@ -11825,7 +11842,9 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1182511842
.vector_4_i64_type,
1182611843
.vector_2_u64_type,
1182711844
.vector_4_u64_type,
11845+
.vector_1_u128_type,
1182811846
.vector_2_u128_type,
11847+
.vector_1_u256_type,
1182911848
.vector_4_f16_type,
1183011849
.vector_8_f16_type,
1183111850
.vector_2_f32_type,
@@ -12108,6 +12127,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1210812127
.u80_type,
1210912128
.u128_type,
1211012129
.i128_type,
12130+
.u256_type,
1211112131
.usize_type,
1211212132
.isize_type,
1211312133
.c_char_type,
@@ -12159,6 +12179,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1215912179
.vector_8_u8_type,
1216012180
.vector_16_u8_type,
1216112181
.vector_32_u8_type,
12182+
.vector_64_u8_type,
1216212183
.vector_4_i16_type,
1216312184
.vector_8_i16_type,
1216412185
.vector_16_i16_type,
@@ -12173,7 +12194,9 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1217312194
.vector_4_i64_type,
1217412195
.vector_2_u64_type,
1217512196
.vector_4_u64_type,
12197+
.vector_1_u128_type,
1217612198
.vector_2_u128_type,
12199+
.vector_1_u256_type,
1217712200
.vector_4_f16_type,
1217812201
.vector_8_f16_type,
1217912202
.vector_2_f32_type,

src/Sema.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36594,6 +36594,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3659436594
.u80_type,
3659536595
.u128_type,
3659636596
.i128_type,
36597+
.u256_type,
3659736598
.usize_type,
3659836599
.isize_type,
3659936600
.c_char_type,
@@ -36634,6 +36635,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3663436635
.vector_8_u8_type,
3663536636
.vector_16_u8_type,
3663636637
.vector_32_u8_type,
36638+
.vector_64_u8_type,
3663736639
.vector_4_i16_type,
3663836640
.vector_8_i16_type,
3663936641
.vector_16_i16_type,
@@ -36648,7 +36650,9 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3664836650
.vector_4_i64_type,
3664936651
.vector_2_u64_type,
3665036652
.vector_4_u64_type,
36653+
.vector_1_u128_type,
3665136654
.vector_2_u128_type,
36655+
.vector_1_u256_type,
3665236656
.vector_4_f16_type,
3665336657
.vector_8_f16_type,
3665436658
.vector_2_f32_type,

src/Type.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ pub fn abiAlignmentInner(
994994
.stage2_x86_64 => {
995995
if (vector_type.child == .bool_type) {
996996
if (vector_type.len > 256 and std.Target.x86.featureSetHas(target.cpu.features, .avx512f)) return .{ .scalar = .@"64" };
997-
if (vector_type.len > 128 and std.Target.x86.featureSetHas(target.cpu.features, .avx2)) return .{ .scalar = .@"32" };
997+
if (vector_type.len > 128 and std.Target.x86.featureSetHas(target.cpu.features, .avx)) return .{ .scalar = .@"32" };
998998
if (vector_type.len > 64) return .{ .scalar = .@"16" };
999999
const bytes = std.math.divCeil(u32, vector_type.len, 8) catch unreachable;
10001000
const alignment = std.math.ceilPowerOfTwoAssert(u32, bytes);
@@ -4050,6 +4050,7 @@ pub const @"u32": Type = .{ .ip_index = .u32_type };
40504050
pub const @"u64": Type = .{ .ip_index = .u64_type };
40514051
pub const @"u80": Type = .{ .ip_index = .u80_type };
40524052
pub const @"u128": Type = .{ .ip_index = .u128_type };
4053+
pub const @"u256": Type = .{ .ip_index = .u256_type };
40534054

40544055
pub const @"i8": Type = .{ .ip_index = .i8_type };
40554056
pub const @"i16": Type = .{ .ip_index = .i16_type };
@@ -4105,6 +4106,7 @@ pub const vector_4_u8: Type = .{ .ip_index = .vector_4_u8_type };
41054106
pub const vector_8_u8: Type = .{ .ip_index = .vector_8_u8_type };
41064107
pub const vector_16_u8: Type = .{ .ip_index = .vector_16_u8_type };
41074108
pub const vector_32_u8: Type = .{ .ip_index = .vector_32_u8_type };
4109+
pub const vector_64_u8: Type = .{ .ip_index = .vector_64_u8_type };
41084110
pub const vector_4_i16: Type = .{ .ip_index = .vector_4_i16_type };
41094111
pub const vector_8_i16: Type = .{ .ip_index = .vector_8_i16_type };
41104112
pub const vector_16_i16: Type = .{ .ip_index = .vector_16_i16_type };
@@ -4119,7 +4121,9 @@ pub const vector_2_i64: Type = .{ .ip_index = .vector_2_i64_type };
41194121
pub const vector_4_i64: Type = .{ .ip_index = .vector_4_i64_type };
41204122
pub const vector_2_u64: Type = .{ .ip_index = .vector_2_u64_type };
41214123
pub const vector_4_u64: Type = .{ .ip_index = .vector_4_u64_type };
4124+
pub const vector_1_u128: Type = .{ .ip_index = .vector_1_u128_type };
41224125
pub const vector_2_u128: Type = .{ .ip_index = .vector_2_u128_type };
4126+
pub const vector_1_u256: Type = .{ .ip_index = .vector_1_u256_type };
41234127
pub const vector_4_f16: Type = .{ .ip_index = .vector_4_f16_type };
41244128
pub const vector_8_f16: Type = .{ .ip_index = .vector_8_f16_type };
41254129
pub const vector_2_f32: Type = .{ .ip_index = .vector_2_f32_type };

0 commit comments

Comments
 (0)