Skip to content

Commit 3a493d2

Browse files
committed
x86_64: rewrite bitwise @reduce
1 parent f2077f5 commit 3a493d2

15 files changed

+9674
-1497
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
@@ -4535,6 +4535,7 @@ pub const Index = enum(u32) {
45354535
u80_type,
45364536
u128_type,
45374537
i128_type,
4538+
u256_type,
45384539
usize_type,
45394540
isize_type,
45404541
c_char_type,
@@ -4581,6 +4582,7 @@ pub const Index = enum(u32) {
45814582
vector_8_u8_type,
45824583
vector_16_u8_type,
45834584
vector_32_u8_type,
4585+
vector_64_u8_type,
45844586
vector_4_i16_type,
45854587
vector_8_i16_type,
45864588
vector_16_i16_type,
@@ -4595,7 +4597,9 @@ pub const Index = enum(u32) {
45954597
vector_4_i64_type,
45964598
vector_2_u64_type,
45974599
vector_4_u64_type,
4600+
vector_1_u128_type,
45984601
vector_2_u128_type,
4602+
vector_1_u256_type,
45994603
vector_4_f16_type,
46004604
vector_8_f16_type,
46014605
vector_2_f32_type,
@@ -5009,6 +5013,11 @@ pub const static_keys = [_]Key{
50095013
.bits = 128,
50105014
} },
50115015

5016+
.{ .int_type = .{
5017+
.signedness = .unsigned,
5018+
.bits = 256,
5019+
} },
5020+
50125021
.{ .simple_type = .usize },
50135022
.{ .simple_type = .isize },
50145023
.{ .simple_type = .c_char },
@@ -5112,6 +5121,8 @@ pub const static_keys = [_]Key{
51125121
.{ .vector_type = .{ .len = 16, .child = .u8_type } },
51135122
// @Vector(32, u8)
51145123
.{ .vector_type = .{ .len = 32, .child = .u8_type } },
5124+
// @Vector(64, u8)
5125+
.{ .vector_type = .{ .len = 64, .child = .u8_type } },
51155126
// @Vector(4, i16)
51165127
.{ .vector_type = .{ .len = 4, .child = .i16_type } },
51175128
// @Vector(8, i16)
@@ -5140,8 +5151,12 @@ pub const static_keys = [_]Key{
51405151
.{ .vector_type = .{ .len = 2, .child = .u64_type } },
51415152
// @Vector(8, u64)
51425153
.{ .vector_type = .{ .len = 4, .child = .u64_type } },
5154+
// @Vector(1, u128)
5155+
.{ .vector_type = .{ .len = 1, .child = .u128_type } },
51435156
// @Vector(2, u128)
51445157
.{ .vector_type = .{ .len = 2, .child = .u128_type } },
5158+
// @Vector(1, u256)
5159+
.{ .vector_type = .{ .len = 1, .child = .u256_type } },
51455160
// @Vector(4, f16)
51465161
.{ .vector_type = .{ .len = 4, .child = .f16_type } },
51475162
// @Vector(8, f16)
@@ -11754,6 +11769,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1175411769
.u80_type,
1175511770
.u128_type,
1175611771
.i128_type,
11772+
.u256_type,
1175711773
.usize_type,
1175811774
.isize_type,
1175911775
.c_char_type,
@@ -11798,6 +11814,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1179811814
.vector_8_u8_type,
1179911815
.vector_16_u8_type,
1180011816
.vector_32_u8_type,
11817+
.vector_64_u8_type,
1180111818
.vector_4_i16_type,
1180211819
.vector_8_i16_type,
1180311820
.vector_16_i16_type,
@@ -11812,7 +11829,9 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1181211829
.vector_4_i64_type,
1181311830
.vector_2_u64_type,
1181411831
.vector_4_u64_type,
11832+
.vector_1_u128_type,
1181511833
.vector_2_u128_type,
11834+
.vector_1_u256_type,
1181611835
.vector_4_f16_type,
1181711836
.vector_8_f16_type,
1181811837
.vector_2_f32_type,
@@ -12095,6 +12114,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1209512114
.u80_type,
1209612115
.u128_type,
1209712116
.i128_type,
12117+
.u256_type,
1209812118
.usize_type,
1209912119
.isize_type,
1210012120
.c_char_type,
@@ -12146,6 +12166,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1214612166
.vector_8_u8_type,
1214712167
.vector_16_u8_type,
1214812168
.vector_32_u8_type,
12169+
.vector_64_u8_type,
1214912170
.vector_4_i16_type,
1215012171
.vector_8_i16_type,
1215112172
.vector_16_i16_type,
@@ -12160,7 +12181,9 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1216012181
.vector_4_i64_type,
1216112182
.vector_2_u64_type,
1216212183
.vector_4_u64_type,
12184+
.vector_1_u128_type,
1216312185
.vector_2_u128_type,
12186+
.vector_1_u256_type,
1216412187
.vector_4_f16_type,
1216512188
.vector_8_f16_type,
1216612189
.vector_2_f32_type,

src/Sema.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36583,6 +36583,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3658336583
.u80_type,
3658436584
.u128_type,
3658536585
.i128_type,
36586+
.u256_type,
3658636587
.usize_type,
3658736588
.isize_type,
3658836589
.c_char_type,
@@ -36623,6 +36624,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3662336624
.vector_8_u8_type,
3662436625
.vector_16_u8_type,
3662536626
.vector_32_u8_type,
36627+
.vector_64_u8_type,
3662636628
.vector_4_i16_type,
3662736629
.vector_8_i16_type,
3662836630
.vector_16_i16_type,
@@ -36637,7 +36639,9 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3663736639
.vector_4_i64_type,
3663836640
.vector_2_u64_type,
3663936641
.vector_4_u64_type,
36642+
.vector_1_u128_type,
3664036643
.vector_2_u128_type,
36644+
.vector_1_u256_type,
3664136645
.vector_4_f16_type,
3664236646
.vector_8_f16_type,
3664336647
.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)