authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-09-10 22:25:55-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-09-10 22:40:26-04:00
loge313b387a039fe4471462db0a63eea9b29c84a96
tree9ba8337cb78f657be61c998ba70e4e26b734f82b
parent1a0a9d7d59b78e5d97142d867bece78fc477e9a7

x86_64: delete usages of avx2 `vpack?s??`

This instruction actually has fairly useless semantics, and even the cases that were semantically correct could save 1 cycle of latency by using a different sequnce involving the avx version instead. Closes #25174

2 files changed, 325 insertions(+), 57 deletions(-)

src/arch/x86_64/CodeGen.zig+119-37
......@@ -22283,8 +22283,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2228322283 .{ ._, .vp_w, .movsxb, .dst0y, .src0x, ._, ._ },
2228422284 .{ ._, .vp_w, .movsxb, .tmp0y, .src1x, ._, ._ },
2228522285 .{ ._, .vp_w, .mull, .dst0y, .dst0y, .tmp0y, ._ },
22286 .{ ._, .vp_b, .ackssw, .dst0y, .dst0y, .dst0y, ._ },
22287 .{ ._, .v_q, .perm, .dst0y, .dst0y, .ui(0b10_00_10_00), ._ },
22286 .{ ._, .v_i128, .extract, .tmp0x, .dst0y, .ui(1), ._ },
22287 .{ ._, .vp_b, .ackssw, .dst0x, .dst0x, .tmp0x, ._ },
2228822288 } },
2228922289 }, .{
2229022290 .required_features = .{ .avx, null, null, null },
......@@ -22414,8 +22414,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2241422414 .{ ._, .vp_w, .movzxb, .dst0y, .src0x, ._, ._ },
2241522415 .{ ._, .vp_w, .movzxb, .tmp0y, .src1x, ._, ._ },
2241622416 .{ ._, .vp_w, .mull, .dst0y, .dst0y, .tmp0y, ._ },
22417 .{ ._, .vp_b, .ackusw, .dst0y, .dst0y, .dst0y, ._ },
22418 .{ ._, .v_q, .perm, .dst0y, .dst0y, .ui(0b10_00_10_00), ._ },
22417 .{ ._, .v_i128, .extract, .tmp0x, .dst0y, .ui(1), ._ },
22418 .{ ._, .vp_b, .ackusw, .dst0x, .dst0x, .tmp0x, ._ },
2241922419 } },
2242022420 }, .{
2242122421 .required_features = .{ .avx2, null, null, null },
......@@ -22447,8 +22447,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2244722447 .{ .@"0:", .vp_w, .movsxb, .tmp1y, .memia(.src0x, .tmp0, .add_unaligned_size), ._, ._ },
2244822448 .{ ._, .vp_w, .movsxb, .tmp2y, .memia(.src1x, .tmp0, .add_unaligned_size), ._, ._ },
2244922449 .{ ._, .vp_w, .mull, .tmp1y, .tmp1y, .tmp2y, ._ },
22450 .{ ._, .vp_b, .ackssw, .tmp1y, .tmp1y, .tmp1y, ._ },
22451 .{ ._, .v_q, .perm, .tmp1y, .tmp1y, .ui(0b10_00_10_00), ._ },
22450 .{ ._, .v_i128, .extract, .tmp2x, .tmp1y, .ui(1), ._ },
22451 .{ ._, .vp_b, .ackssw, .tmp1x, .tmp1x, .tmp2x, ._ },
2245222452 .{ ._, .v_dqa, .mov, .memia(.dst0x, .tmp0, .add_unaligned_size), .tmp1x, ._, ._ },
2245322453 .{ ._, ._, .add, .tmp0p, .si(16), ._, ._ },
2245422454 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
......@@ -22659,8 +22659,8 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
2265922659 .{ .@"0:", .vp_w, .movzxb, .tmp1y, .memia(.src0x, .tmp0, .add_unaligned_size), ._, ._ },
2266022660 .{ ._, .vp_w, .movzxb, .tmp2y, .memia(.src1x, .tmp0, .add_unaligned_size), ._, ._ },
2266122661 .{ ._, .vp_w, .mull, .tmp1y, .tmp1y, .tmp2y, ._ },
22662 .{ ._, .vp_b, .ackusw, .tmp1y, .tmp1y, .tmp1y, ._ },
22663 .{ ._, .v_q, .perm, .tmp1y, .tmp1y, .ui(0b10_00_10_00), ._ },
22662 .{ ._, .v_i128, .extract, .tmp2x, .tmp1y, .ui(1), ._ },
22663 .{ ._, .vp_b, .ackusw, .tmp1x, .tmp1x, .tmp2x, ._ },
2266422664 .{ ._, .v_dqa, .mov, .memia(.dst0x, .tmp0, .add_unaligned_size), .tmp1x, ._, ._ },
2266522665 .{ ._, ._, .add, .tmp0p, .si(16), ._, ._ },
2266622666 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
......@@ -82559,7 +82559,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
8255982559 .{ .type = .u32, .kind = .{ .rc = .general_purpose } },
8256082560 .{ .type = .u16, .kind = .{ .rc = .general_purpose } },
8256182561 .{ .kind = .{ .rc = .sse } },
82562 .unused,
82562 .{ .kind = .{ .rc = .sse } },
8256382563 .unused,
8256482564 .unused,
8256582565 .unused,
......@@ -82576,8 +82576,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
8257682576 .{ ._, ._, .xor, .tmp1d, .tmp1d, ._, ._ },
8257782577 .{ .@"0:", .v_dqu, .mov, .tmp3y, .memia(.src0y, .tmp0, .add_size), ._, ._ },
8257882578 .{ ._, .vp_w, .cmpeq, .tmp3y, .tmp3y, .memia(.src1y, .tmp0, .add_size), ._ },
82579 .{ ._, .vp_b, .ackssw, .tmp3y, .tmp3y, .tmp3y, ._ },
82580 .{ ._, .vp_b, .movmsk, .tmp2d, .tmp3y, ._, ._ },
82579 .{ ._, .v_i128, .extract, .tmp4x, .tmp3y, .ui(1), ._ },
82580 .{ ._, .vp_b, .ackssw, .tmp3x, .tmp3x, .tmp4x, ._ },
82581 .{ ._, .vp_b, .movmsk, .tmp2d, .tmp3x, ._, ._ },
8258182582 .{ ._, ._, .mov, .memi(.dst0w, .tmp1), .tmp2w, ._, ._ },
8258282583 .{ ._, ._, .lea, .tmp1d, .lead(.tmp1, 2), ._, ._ },
8258382584 .{ ._, ._, .add, .tmp0p, .si(32), ._, ._ },
......@@ -82588,8 +82589,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
8258882589 .{ ._, ._, .xor, .tmp1d, .tmp1d, ._, ._ },
8258982590 .{ .@"0:", .v_dqu, .mov, .tmp3y, .memia(.src0y, .tmp0, .add_size), ._, ._ },
8259082591 .{ ._, .vp_w, .cmpeq, .tmp3y, .tmp3y, .memia(.src1y, .tmp0, .add_size), ._ },
82591 .{ ._, .vp_b, .ackssw, .tmp3y, .tmp3y, .tmp3y, ._ },
82592 .{ ._, .vp_b, .movmsk, .tmp2d, .tmp3y, ._, ._ },
82592 .{ ._, .v_i128, .extract, .tmp4x, .tmp3y, .ui(1), ._ },
82593 .{ ._, .vp_b, .ackssw, .tmp3x, .tmp3x, .tmp4x, ._ },
82594 .{ ._, .vp_b, .movmsk, .tmp2d, .tmp3x, ._, ._ },
8259382595 .{ ._, ._, .not, .tmp2d, ._, ._, ._ },
8259482596 .{ ._, ._, .mov, .memi(.dst0w, .tmp1), .tmp2w, ._, ._ },
8259582597 .{ ._, ._, .lea, .tmp1d, .lead(.tmp1, 2), ._, ._ },
......@@ -90324,7 +90326,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9032490326 }, .{
9032590327 .required_features = .{ .avx, null, null, null },
9032690328 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .word } }, .any, .any },
90327 .dst_constraints = .{ .{ .scalar_int = .{ .of = .qword, .is = .byte } }, .any },
90329 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .byte } }, .any },
9032890330 .patterns = &.{
9032990331 .{ .src = .{ .to_sse, .none, .none } },
9033090332 },
......@@ -90346,7 +90348,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9034690348 }, .{
9034790349 .required_features = .{ .sse2, null, null, null },
9034890350 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .word } }, .any, .any },
90349 .dst_constraints = .{ .{ .scalar_int = .{ .of = .qword, .is = .byte } }, .any },
90351 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .byte } }, .any },
9035090352 .patterns = &.{
9035190353 .{ .src = .{ .to_mut_sse, .none, .none } },
9035290354 },
......@@ -90361,20 +90363,46 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9036190363 .patterns = &.{
9036290364 .{ .src = .{ .to_sse, .none, .none } },
9036390365 },
90364 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90366 .dst_temps = .{ .{ .rc = .sse }, .unused },
90367 .each = .{ .once = &.{
90368 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90369 .{ ._, .vp_b, .ackssw, .dst0x, .src0x, .dst0x, ._ },
90370 } },
90371 }, .{
90372 .required_features = .{ .avx, null, null, null },
90373 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .word } }, .any, .any },
90374 .dst_constraints = .{ .{ .scalar_signed_int = .{ .of = .xword, .is = .byte } }, .any },
90375 .patterns = &.{
90376 .{ .src = .{ .to_sse, .none, .none } },
90377 },
90378 .dst_temps = .{ .{ .rc = .sse }, .unused },
9036590379 .each = .{ .once = &.{
90366 .{ ._, .vp_b, .ackssw, .dst0y, .src0y, .dst0y, ._ },
90380 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90381 .{ ._, .vp_b, .ackssw, .dst0x, .src0x, .dst0x, ._ },
9036790382 } },
9036890383 }, .{
9036990384 .required_features = .{ .avx2, null, null, null },
9037090385 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .word } }, .any, .any },
90371 .dst_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .byte } }, .any },
90386 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .xword, .is = .byte } }, .any },
9037290387 .patterns = &.{
9037390388 .{ .src = .{ .to_sse, .none, .none } },
9037490389 },
90375 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90390 .dst_temps = .{ .{ .rc = .sse }, .unused },
9037690391 .each = .{ .once = &.{
90377 .{ ._, .vp_b, .ackusw, .dst0y, .src0y, .dst0y, ._ },
90392 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90393 .{ ._, .vp_b, .ackusw, .dst0x, .src0x, .dst0x, ._ },
90394 } },
90395 }, .{
90396 .required_features = .{ .avx, null, null, null },
90397 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .word } }, .any, .any },
90398 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .xword, .is = .byte } }, .any },
90399 .patterns = &.{
90400 .{ .src = .{ .to_sse, .none, .none } },
90401 },
90402 .dst_temps = .{ .{ .rc = .sse }, .unused },
90403 .each = .{ .once = &.{
90404 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90405 .{ ._, .vp_b, .ackusw, .dst0x, .src0x, .dst0x, ._ },
9037890406 } },
9037990407 }, .{
9038090408 .required_features = .{ .slow_incdec, null, null, null },
......@@ -90448,7 +90476,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9044890476 }, .{
9044990477 .required_features = .{ .avx, null, null, null },
9045090478 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .dword } }, .any, .any },
90451 .dst_constraints = .{ .{ .scalar_int = .{ .of = .dword, .is = .byte } }, .any },
90479 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .dword, .is = .byte } }, .any },
9045290480 .patterns = &.{
9045390481 .{ .src = .{ .to_sse, .none, .none } },
9045490482 },
......@@ -90472,7 +90500,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9047290500 }, .{
9047390501 .required_features = .{ .sse4_1, null, null, null },
9047490502 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .dword } }, .any, .any },
90475 .dst_constraints = .{ .{ .scalar_int = .{ .of = .dword, .is = .byte } }, .any },
90503 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .dword, .is = .byte } }, .any },
9047690504 .patterns = &.{
9047790505 .{ .src = .{ .to_mut_sse, .none, .none } },
9047890506 },
......@@ -90488,22 +90516,50 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9048890516 .patterns = &.{
9048990517 .{ .src = .{ .to_sse, .none, .none } },
9049090518 },
90491 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90519 .dst_temps = .{ .{ .rc = .sse }, .unused },
9049290520 .each = .{ .once = &.{
90493 .{ ._, .vp_w, .ackssd, .dst0y, .src0y, .dst0y, ._ },
90494 .{ ._, .vp_b, .ackssw, .dst0y, .dst0y, .dst0y, ._ },
90521 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90522 .{ ._, .vp_w, .ackssd, .dst0x, .src0x, .dst0x, ._ },
90523 .{ ._, .vp_b, .ackssw, .dst0x, .dst0x, .dst0x, ._ },
90524 } },
90525 }, .{
90526 .required_features = .{ .avx, null, null, null },
90527 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90528 .dst_constraints = .{ .{ .scalar_signed_int = .{ .of = .qword, .is = .byte } }, .any },
90529 .patterns = &.{
90530 .{ .src = .{ .to_sse, .none, .none } },
90531 },
90532 .dst_temps = .{ .{ .rc = .sse }, .unused },
90533 .each = .{ .once = &.{
90534 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90535 .{ ._, .vp_w, .ackssd, .dst0x, .src0x, .dst0x, ._ },
90536 .{ ._, .vp_b, .ackssw, .dst0x, .dst0x, .dst0x, ._ },
9049590537 } },
9049690538 }, .{
9049790539 .required_features = .{ .avx2, null, null, null },
9049890540 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90499 .dst_constraints = .{ .{ .scalar_int = .{ .of = .qword, .is = .byte } }, .any },
90541 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .byte } }, .any },
9050090542 .patterns = &.{
9050190543 .{ .src = .{ .to_sse, .none, .none } },
9050290544 },
90503 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90545 .dst_temps = .{ .{ .rc = .sse }, .unused },
90546 .each = .{ .once = &.{
90547 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90548 .{ ._, .vp_w, .ackusd, .dst0x, .src0x, .dst0x, ._ },
90549 .{ ._, .vp_b, .ackusw, .dst0x, .dst0x, .dst0x, ._ },
90550 } },
90551 }, .{
90552 .required_features = .{ .avx, null, null, null },
90553 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90554 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .byte } }, .any },
90555 .patterns = &.{
90556 .{ .src = .{ .to_sse, .none, .none } },
90557 },
90558 .dst_temps = .{ .{ .rc = .sse }, .unused },
9050490559 .each = .{ .once = &.{
90505 .{ ._, .vp_w, .ackusd, .dst0y, .src0y, .dst0y, ._ },
90506 .{ ._, .vp_b, .ackusw, .dst0y, .dst0y, .dst0y, ._ },
90560 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90561 .{ ._, .vp_w, .ackusd, .dst0x, .src0x, .dst0x, ._ },
90562 .{ ._, .vp_b, .ackusw, .dst0x, .dst0x, .dst0x, ._ },
9050790563 } },
9050890564 }, .{
9050990565 .required_features = .{ .slow_incdec, null, null, null },
......@@ -90722,7 +90778,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9072290778 }, .{
9072390779 .required_features = .{ .avx, null, null, null },
9072490780 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .dword } }, .any, .any },
90725 .dst_constraints = .{ .{ .scalar_int = .{ .of = .qword, .is = .word } }, .any },
90781 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .word } }, .any },
9072690782 .patterns = &.{
9072790783 .{ .src = .{ .to_sse, .none, .none } },
9072890784 },
......@@ -90744,7 +90800,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9074490800 }, .{
9074590801 .required_features = .{ .sse4_1, null, null, null },
9074690802 .src_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .dword } }, .any, .any },
90747 .dst_constraints = .{ .{ .scalar_int = .{ .of = .qword, .is = .word } }, .any },
90803 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .qword, .is = .word } }, .any },
9074890804 .patterns = &.{
9074990805 .{ .src = .{ .to_mut_sse, .none, .none } },
9075090806 },
......@@ -90759,20 +90815,46 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9075990815 .patterns = &.{
9076090816 .{ .src = .{ .to_sse, .none, .none } },
9076190817 },
90762 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90818 .dst_temps = .{ .{ .rc = .sse }, .unused },
9076390819 .each = .{ .once = &.{
90764 .{ ._, .vp_w, .ackssd, .dst0y, .src0y, .dst0y, ._ },
90820 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90821 .{ ._, .vp_w, .ackssd, .dst0x, .src0x, .dst0x, ._ },
90822 } },
90823 }, .{
90824 .required_features = .{ .avx, null, null, null },
90825 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90826 .dst_constraints = .{ .{ .scalar_signed_int = .{ .of = .xword, .is = .word } }, .any },
90827 .patterns = &.{
90828 .{ .src = .{ .to_sse, .none, .none } },
90829 },
90830 .dst_temps = .{ .{ .rc = .sse }, .unused },
90831 .each = .{ .once = &.{
90832 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90833 .{ ._, .vp_w, .ackssd, .dst0x, .src0x, .dst0x, ._ },
9076590834 } },
9076690835 }, .{
9076790836 .required_features = .{ .avx2, null, null, null },
9076890837 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90769 .dst_constraints = .{ .{ .scalar_int = .{ .of = .xword, .is = .word } }, .any },
90838 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .xword, .is = .word } }, .any },
9077090839 .patterns = &.{
9077190840 .{ .src = .{ .to_sse, .none, .none } },
9077290841 },
90773 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
90842 .dst_temps = .{ .{ .rc = .sse }, .unused },
9077490843 .each = .{ .once = &.{
90775 .{ ._, .vp_w, .ackusd, .dst0y, .src0y, .dst0y, ._ },
90844 .{ ._, .v_i128, .extract, .dst0x, .src0y, .ui(1), ._ },
90845 .{ ._, .vp_w, .ackusd, .dst0x, .src0x, .dst0x, ._ },
90846 } },
90847 }, .{
90848 .required_features = .{ .avx, null, null, null },
90849 .src_constraints = .{ .{ .scalar_int = .{ .of = .yword, .is = .dword } }, .any, .any },
90850 .dst_constraints = .{ .{ .scalar_unsigned_int = .{ .of = .xword, .is = .word } }, .any },
90851 .patterns = &.{
90852 .{ .src = .{ .to_sse, .none, .none } },
90853 },
90854 .dst_temps = .{ .{ .rc = .sse }, .unused },
90855 .each = .{ .once = &.{
90856 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
90857 .{ ._, .vp_w, .ackusd, .dst0x, .src0x, .dst0x, ._ },
9077690858 } },
9077790859 }, .{
9077890860 .src_constraints = .{ .{ .multiple_scalar_int = .{ .of = .dword, .is = .dword } }, .any, .any },
......@@ -92413,7 +92495,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
9241392495 .clobbers = .{ .eflags = true },
9241492496 .each = .{ .once = &.{
9241592497 .{ ._, ._, .mov, .tmp0p, .sa(.src0, .sub_unaligned_size), ._, ._ },
92416 .{ .@"0:", .vp_d, .movzxb, .tmp1y, .memia(.src0x, .tmp0, .add_unaligned_size), ._, ._ },
92498 .{ .@"0:", .vp_d, .movzxb, .tmp1y, .memia(.src0q, .tmp0, .add_unaligned_size), ._, ._ },
9241792499 .{ ._, .v_dqa, .mov, .memsia(.dst0y, .@"4", .tmp0, .add_unaligned_size), .tmp1y, ._, ._ },
9241892500 .{ ._, ._, .add, .tmp0p, .si(8), ._, ._ },
9241992501 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
test/behavior/cast.zig+206-20
......@@ -607,26 +607,212 @@ test "@intCast on vector" {
607607
608608 const S = struct {
609609 fn doTheTest() !void {
610 // Upcast (implicit, equivalent to @intCast)
611 var up0: @Vector(2, u8) = [_]u8{ 0x55, 0xaa };
612 _ = &up0;
613 const up1: @Vector(2, u16) = up0;
614 const up2: @Vector(2, u32) = up0;
615 const up3: @Vector(2, u64) = up0;
616 // Downcast (safety-checked)
617 var down0 = up3;
618 _ = &down0;
619 const down1: @Vector(2, u32) = @intCast(down0);
620 const down2: @Vector(2, u16) = @intCast(down0);
621 const down3: @Vector(2, u8) = @intCast(down0);
622
623 try expect(mem.eql(u16, &@as([2]u16, up1), &[2]u16{ 0x55, 0xaa }));
624 try expect(mem.eql(u32, &@as([2]u32, up2), &[2]u32{ 0x55, 0xaa }));
625 try expect(mem.eql(u64, &@as([2]u64, up3), &[2]u64{ 0x55, 0xaa }));
626
627 try expect(mem.eql(u32, &@as([2]u32, down1), &[2]u32{ 0x55, 0xaa }));
628 try expect(mem.eql(u16, &@as([2]u16, down2), &[2]u16{ 0x55, 0xaa }));
629 try expect(mem.eql(u8, &@as([2]u8, down3), &[2]u8{ 0x55, 0xaa }));
610 {
611 // Upcast (implicit, equivalent to @intCast)
612 var up0: @Vector(2, u8) = .{ 0x55, 0xaa };
613 _ = &up0;
614 const up1: @Vector(2, u16) = up0;
615 const up2: @Vector(2, u32) = up0;
616 const up3: @Vector(2, u64) = up0;
617
618 try expect(mem.eql(u16, &@as([2]u16, up1), &[2]u16{ 0x55, 0xaa }));
619 try expect(mem.eql(u32, &@as([2]u32, up2), &[2]u32{ 0x55, 0xaa }));
620 try expect(mem.eql(u64, &@as([2]u64, up3), &[2]u64{ 0x55, 0xaa }));
621
622 {
623 // Downcast (safety-checked)
624 const down2: @Vector(2, u32) = @intCast(up3);
625 const down1: @Vector(2, u16) = @intCast(up3);
626 const down0: @Vector(2, u8) = @intCast(up3);
627
628 try expect(mem.eql(u32, &@as([2]u32, down2), &[2]u32{ 0x55, 0xaa }));
629 try expect(mem.eql(u16, &@as([2]u16, down1), &[2]u16{ 0x55, 0xaa }));
630 try expect(mem.eql(u8, &@as([2]u8, down0), &[2]u8{ 0x55, 0xaa }));
631 }
632
633 {
634 // Downcast (safety-checked)
635 const down1: @Vector(2, u16) = @intCast(up2);
636 const down0: @Vector(2, u8) = @intCast(up2);
637
638 try expect(mem.eql(u16, &@as([2]u16, down1), &[2]u16{ 0x55, 0xaa }));
639 try expect(mem.eql(u8, &@as([2]u8, down0), &[2]u8{ 0x55, 0xaa }));
640 }
641
642 {
643 // Downcast (safety-checked)
644 const down0: @Vector(2, u8) = @intCast(up1);
645
646 try expect(mem.eql(u8, &@as([2]u8, down0), &[2]u8{ 0x55, 0xaa }));
647 }
648 }
649 {
650 // Upcast (implicit, equivalent to @intCast)
651 var up0: @Vector(4, u8) = .{ 0x00, 0x55, 0xaa, 0xff };
652 _ = &up0;
653 const up1: @Vector(4, u16) = up0;
654 const up2: @Vector(4, u32) = up0;
655 const up3: @Vector(4, u64) = up0;
656
657 try expect(mem.eql(u16, &@as([4]u16, up1), &[4]u16{ 0x00, 0x55, 0xaa, 0xff }));
658 try expect(mem.eql(u32, &@as([4]u32, up2), &[4]u32{ 0x00, 0x55, 0xaa, 0xff }));
659 try expect(mem.eql(u64, &@as([4]u64, up3), &[4]u64{ 0x00, 0x55, 0xaa, 0xff }));
660
661 {
662 // Downcast (safety-checked)
663 const down2: @Vector(4, u32) = @intCast(up3);
664 const down1: @Vector(4, u16) = @intCast(up3);
665 const down0: @Vector(4, u8) = @intCast(up3);
666
667 try expect(mem.eql(u32, &@as([4]u32, down2), &[4]u32{ 0x00, 0x55, 0xaa, 0xff }));
668 try expect(mem.eql(u16, &@as([4]u16, down1), &[4]u16{ 0x00, 0x55, 0xaa, 0xff }));
669 try expect(mem.eql(u8, &@as([4]u8, down0), &[4]u8{ 0x00, 0x55, 0xaa, 0xff }));
670 }
671
672 {
673 // Downcast (safety-checked)
674 const down1: @Vector(4, u16) = @intCast(up2);
675 const down0: @Vector(4, u8) = @intCast(up2);
676
677 try expect(mem.eql(u16, &@as([4]u16, down1), &[4]u16{ 0x00, 0x55, 0xaa, 0xff }));
678 try expect(mem.eql(u8, &@as([4]u8, down0), &[4]u8{ 0x00, 0x55, 0xaa, 0xff }));
679 }
680
681 {
682 // Downcast (safety-checked)
683 const down0: @Vector(4, u8) = @intCast(up1);
684
685 try expect(mem.eql(u8, &@as([4]u8, down0), &[4]u8{ 0x00, 0x55, 0xaa, 0xff }));
686 }
687 }
688 {
689 // Upcast (implicit, equivalent to @intCast)
690 var up0: @Vector(8, u8) = .{
691 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
692 };
693 _ = &up0;
694 const up1: @Vector(8, u16) = up0;
695 const up2: @Vector(8, u32) = up0;
696 const up3: @Vector(8, u64) = up0;
697
698 try expect(mem.eql(u16, &@as([8]u16, up1), &[8]u16{
699 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
700 }));
701 try expect(mem.eql(u32, &@as([8]u32, up2), &[8]u32{
702 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
703 }));
704 try expect(mem.eql(u64, &@as([8]u64, up3), &[8]u64{
705 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
706 }));
707
708 {
709 // Downcast (safety-checked)
710 const down2: @Vector(8, u32) = @intCast(up3);
711 const down1: @Vector(8, u16) = @intCast(up3);
712 const down0: @Vector(8, u8) = @intCast(up3);
713
714 try expect(mem.eql(u32, &@as([8]u32, down2), &[8]u32{
715 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
716 }));
717 try expect(mem.eql(u16, &@as([8]u16, down1), &[8]u16{
718 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
719 }));
720 try expect(mem.eql(u8, &@as([8]u8, down0), &[8]u8{
721 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
722 }));
723 }
724
725 {
726 // Downcast (safety-checked)
727 const down1: @Vector(8, u16) = @intCast(up2);
728 const down0: @Vector(8, u8) = @intCast(up2);
729
730 try expect(mem.eql(u16, &@as([8]u16, down1), &[8]u16{
731 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
732 }));
733 try expect(mem.eql(u8, &@as([8]u8, down0), &[8]u8{
734 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
735 }));
736 }
737
738 {
739 // Downcast (safety-checked)
740 const down0: @Vector(8, u8) = @intCast(up1);
741
742 try expect(mem.eql(u8, &@as([8]u8, down0), &[8]u8{
743 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
744 }));
745 }
746 }
747 {
748 // Upcast (implicit, equivalent to @intCast)
749 var up0: @Vector(16, u8) = .{
750 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
751 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
752 };
753 _ = &up0;
754 const up1: @Vector(16, u16) = up0;
755 const up2: @Vector(16, u32) = up0;
756 const up3: @Vector(16, u64) = up0;
757
758 try expect(mem.eql(u16, &@as([16]u16, up1), &[16]u16{
759 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
760 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
761 }));
762 try expect(mem.eql(u32, &@as([16]u32, up2), &[16]u32{
763 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
764 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
765 }));
766 try expect(mem.eql(u64, &@as([16]u64, up3), &[16]u64{
767 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
768 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
769 }));
770
771 {
772 // Downcast (safety-checked)
773 const down2: @Vector(16, u32) = @intCast(up3);
774 const down1: @Vector(16, u16) = @intCast(up3);
775 const down0: @Vector(16, u8) = @intCast(up3);
776
777 try expect(mem.eql(u32, &@as([16]u32, down2), &[16]u32{
778 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
779 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
780 }));
781 try expect(mem.eql(u16, &@as([16]u16, down1), &[16]u16{
782 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
783 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
784 }));
785 try expect(mem.eql(u8, &@as([16]u8, down0), &[16]u8{
786 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
787 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
788 }));
789 }
790
791 {
792 // Downcast (safety-checked)
793 const down1: @Vector(16, u16) = @intCast(up2);
794 const down0: @Vector(16, u8) = @intCast(up2);
795
796 try expect(mem.eql(u16, &@as([16]u16, down1), &[16]u16{
797 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
798 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
799 }));
800 try expect(mem.eql(u8, &@as([16]u8, down0), &[16]u8{
801 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
802 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
803 }));
804 }
805
806 {
807 // Downcast (safety-checked)
808 const down0: @Vector(16, u8) = @intCast(up1);
809
810 try expect(mem.eql(u8, &@as([16]u8, down0), &[16]u8{
811 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
812 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
813 }));
814 }
815 }
630816 }
631817 };
632818