authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-10-12 10:23:52-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-10-13 09:47:51+02:00
log16d31ceed5de91b469e010b4a8d515236ad6bf14
tree9668c5531b93fd61cefad9d5b5fea69141437d05
parent86dc5ce250b77caf76ff5004de07a0cef80f10bf

x86_64: fix reduce evaluation order

Closes #37197

3 files changed, 200 insertions(+), 23 deletions(-)

src/codegen/x86_64/CodeGen.zig+150-23
...@@ -156319,10 +156319,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156319,10 +156319,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156319 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },156319 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
156320 .each = .{ .once = &.{156320 .each = .{ .once = &.{
156321 .{ ._, .v_ps, .cvtph2, .dst0x, .src0q, ._, ._ },156321 .{ ._, .v_ps, .cvtph2, .dst0x, .src0q, ._, ._ },
156322 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b11_10) },
156323 .{ ._, .v_ss, .add, .dst0x, .dst0x, .tmp0x, ._ },
156324 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b01) },156322 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b01) },
156325 .{ ._, .v_ss, .add, .dst0x, .dst0x, .tmp0x, ._ },156323 .{ ._, .v_ss, .add, .dst0x, .dst0x, .tmp0x, ._ },
156324 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b11_10) },
156325 .{ ._, .v_ss, .add, .dst0x, .dst0x, .tmp0x, ._ },
156326 .{ ._, .v_, .cvtps2ph, .dst0q, .dst0x, .rm(.{}), ._ },156326 .{ ._, .v_, .cvtps2ph, .dst0q, .dst0x, .rm(.{}), ._ },
156327 } },156327 } },
156328 }, .{156328 }, .{
...@@ -156614,9 +156614,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156614,9 +156614,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156614 },156614 },
156615 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },156615 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
156616 .each = .{ .once = &.{156616 .each = .{ .once = &.{
156617 .{ ._, .v_ps, .movhl, .tmp0x, .src0x, .src0x, ._ },156617 .{ ._, .v_ps, .shuf, .tmp0x, .src0x, .src0x, .ui(0b01) },
156618 .{ ._, .v_ss, .add, .tmp0x, .src0x, .tmp0x, ._ },156618 .{ ._, .v_ss, .add, .tmp0x, .src0x, .tmp0x, ._ },
156619 .{ ._, .v_ps, .shuf, .dst0x, .src0x, .src0x, .ui(0b01) },156619 .{ ._, .v_ps, .movhl, .dst0x, .src0x, .src0x, ._ },
156620 .{ ._, .v_ss, .add, .dst0x, .tmp0x, .dst0x, ._ },156620 .{ ._, .v_ss, .add, .dst0x, .tmp0x, .dst0x, ._ },
156621 } },156621 } },
156622 }, .{156622 }, .{
...@@ -156646,6 +156646,33 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156646,6 +156646,33 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156646 .{ ._, .h_ps, .add, .dst0x, .src0x, ._, ._ },156646 .{ ._, .h_ps, .add, .dst0x, .src0x, ._, ._ },
156647 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },156647 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },
156648 } },156648 } },
156649 }, .{
156650 .required_features = .{ .sse3, null, null, null },
156651 .dst_constraints = .{ .{ .float = .dword }, .any },
156652 .src_constraints = .{ .{ .exclusive_scalar_float = .{ .of = .xword, .is = .dword } }, .any, .any },
156653 .patterns = &.{
156654 .{ .src = .{ .to_mut_sse, .none, .none } },
156655 },
156656 .extra_temps = .{
156657 .{ .type = .vector_4_f32, .kind = .{ .rc = .sse } },
156658 .unused,
156659 .unused,
156660 .unused,
156661 .unused,
156662 .unused,
156663 .unused,
156664 .unused,
156665 .unused,
156666 .unused,
156667 .unused,
156668 },
156669 .dst_temps = .{ .{ .ref = .src0 }, .unused },
156670 .each = .{ .once = &.{
156671 .{ ._, ._, .movshdup, .tmp0x, .src0x, ._, ._ },
156672 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },
156673 .{ ._, ._ps, .movhl, .tmp0x, .dst0x, ._, ._ },
156674 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },
156675 } },
156649 }, .{156676 }, .{
156650 .required_features = .{ .sse, null, null, null },156677 .required_features = .{ .sse, null, null, null },
156651 .dst_constraints = .{ .{ .float = .dword }, .any },156678 .dst_constraints = .{ .{ .float = .dword }, .any },
...@@ -156668,10 +156695,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156668,10 +156695,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156668 },156695 },
156669 .dst_temps = .{ .{ .ref = .src0 }, .unused },156696 .dst_temps = .{ .{ .ref = .src0 }, .unused },
156670 .each = .{ .once = &.{156697 .each = .{ .once = &.{
156671 .{ ._, ._ps, .xor, .tmp0x, .tmp0x, ._, ._ },156698 .{ ._, ._ps, .mova, .tmp0x, .src0x, ._, ._ },
156699 .{ ._, ._ps, .shuf, .tmp0x, .src0x, .ui(0b01), ._ },
156700 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },
156672 .{ ._, ._ps, .movhl, .tmp0x, .src0x, ._, ._ },156701 .{ ._, ._ps, .movhl, .tmp0x, .src0x, ._, ._ },
156673 .{ ._, ._ss, .add, .tmp0x, .src0x, ._, ._ },
156674 .{ ._, ._ps, .shuf, .dst0x, .src0x, .ui(0b01), ._ },
156675 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },156702 .{ ._, ._ss, .add, .dst0x, .tmp0x, ._, ._ },
156676 } },156703 } },
156677 }, .{156704 }, .{
...@@ -156853,9 +156880,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156853,9 +156880,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156853 },156880 },
156854 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },156881 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
156855 .each = .{ .once = &.{156882 .each = .{ .once = &.{
156856 .{ ._, .v_f128, .extract, .tmp0x, .src0y, .ui(1), ._ },156883 .{ ._, .v_ps, .movhl, .tmp0x, .src0x, .src0x, ._ },
156857 .{ ._, .v_sd, .add, .tmp0x, .src0x, .tmp0x, ._ },156884 .{ ._, .v_sd, .add, .tmp0x, .src0x, .tmp0x, ._ },
156858 .{ ._, .v_ps, .movhl, .dst0x, .src0x, .src0x, ._ },156885 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
156859 .{ ._, .v_sd, .add, .dst0x, .tmp0x, .dst0x, ._ },156886 .{ ._, .v_sd, .add, .dst0x, .tmp0x, .dst0x, ._ },
156860 } },156887 } },
156861 }, .{156888 }, .{
...@@ -156917,6 +156944,44 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -156917,6 +156944,44 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
156917 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },156944 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
156918 } },156945 } },
156919 }, .{156946 }, .{
156947 .required_abi = .gnu,
156948 .required_features = .{ .x87, null, null, null },
156949 .dst_constraints = .{ .{ .float = .qword }, .any },
156950 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },
156951 .patterns = &.{
156952 .{ .src = .{ .to_mem, .none, .none } },
156953 },
156954 .extra_temps = .{
156955 .{ .type = .u16, .kind = .mem },
156956 .{ .type = .isize, .kind = .{ .rc = .general_purpose } },
156957 .{ .type = .f64, .kind = .{ .reg = .st7 } },
156958 .unused,
156959 .unused,
156960 .unused,
156961 .unused,
156962 .unused,
156963 .unused,
156964 .unused,
156965 .unused,
156966 },
156967 .dst_temps = .{ .mem, .unused },
156968 .clobbers = .{ .eflags = true },
156969 .each = .{ .once = &.{
156970 .{ ._, .fn_cw, .st, .tmp0w, ._, ._, ._ },
156971 .{ ._, ._, .movzx, .tmp1d, .memd(.tmp0b, 1), ._, ._ },
156972 .{ ._, ._, .@"and", .memd(.tmp0b, 1), .ui(0b111_1_11_10), ._, ._ },
156973 .{ ._, .f_cw, .ld, .tmp0w, ._, ._, ._ },
156974 .{ ._, ._, .mov, .memd(.tmp0b, 1), .tmp1b, ._, ._ },
156975 .{ ._, ._, .mov, .tmp1p, .sia(8, .src0, .sub_unaligned_size), ._, ._ },
156976 .{ ._, .f_, .ld, .mem(.src0q), ._, ._, ._ },
156977 .{ .@"0:", .f_, .add, .memia(.src0q, .tmp1, .add_unaligned_size), ._, ._, ._ },
156978 .{ ._, ._, .add, .tmp1p, .si(8), ._, ._ },
156979 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
156980 .{ ._, .f_p, .st, .dst0q, ._, ._, ._ },
156981 .{ ._, .f_cw, .ld, .tmp0w, ._, ._, ._ },
156982 } },
156983 }, .{
156984 .required_abi = .msvc,
156920 .required_features = .{ .x87, null, null, null },156985 .required_features = .{ .x87, null, null, null },
156921 .dst_constraints = .{ .{ .float = .qword }, .any },156986 .dst_constraints = .{ .{ .float = .qword }, .any },
156922 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },156987 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },
...@@ -160086,10 +160151,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160086,10 +160151,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160086 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },160151 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
160087 .each = .{ .once = &.{160152 .each = .{ .once = &.{
160088 .{ ._, .v_ps, .cvtph2, .dst0x, .src0q, ._, ._ },160153 .{ ._, .v_ps, .cvtph2, .dst0x, .src0q, ._, ._ },
160089 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b11_10) },
160090 .{ ._, .v_ss, .mul, .dst0x, .dst0x, .tmp0x, ._ },
160091 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b01) },160154 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b01) },
160092 .{ ._, .v_ss, .mul, .dst0x, .dst0x, .tmp0x, ._ },160155 .{ ._, .v_ss, .mul, .dst0x, .dst0x, .tmp0x, ._ },
160156 .{ ._, .v_ps, .shuf, .tmp0x, .dst0x, .dst0x, .ui(0b11_10) },
160157 .{ ._, .v_ss, .mul, .dst0x, .dst0x, .tmp0x, ._ },
160093 .{ ._, .v_, .cvtps2ph, .dst0q, .dst0x, .rm(.{}), ._ },160158 .{ ._, .v_, .cvtps2ph, .dst0q, .dst0x, .rm(.{}), ._ },
160094 } },160159 } },
160095 }, .{160160 }, .{
...@@ -160300,11 +160365,38 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160300,11 +160365,38 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160300 },160365 },
160301 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },160366 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
160302 .each = .{ .once = &.{160367 .each = .{ .once = &.{
160303 .{ ._, .v_ps, .movhl, .tmp0x, .src0x, .src0x, ._ },160368 .{ ._, .v_ps, .shuf, .tmp0x, .src0x, .src0x, .ui(0b01) },
160304 .{ ._, .v_ss, .mul, .tmp0x, .src0x, .tmp0x, ._ },160369 .{ ._, .v_ss, .mul, .tmp0x, .src0x, .tmp0x, ._ },
160305 .{ ._, .v_ps, .shuf, .dst0x, .src0x, .src0x, .ui(0b01) },160370 .{ ._, .v_ps, .movhl, .dst0x, .src0x, .src0x, ._ },
160306 .{ ._, .v_ss, .mul, .dst0x, .tmp0x, .dst0x, ._ },160371 .{ ._, .v_ss, .mul, .dst0x, .tmp0x, .dst0x, ._ },
160307 } },160372 } },
160373 }, .{
160374 .required_features = .{ .sse3, null, null, null },
160375 .dst_constraints = .{ .{ .float = .dword }, .any },
160376 .src_constraints = .{ .{ .exclusive_scalar_float = .{ .of = .xword, .is = .dword } }, .any, .any },
160377 .patterns = &.{
160378 .{ .src = .{ .to_mut_sse, .none, .none } },
160379 },
160380 .extra_temps = .{
160381 .{ .type = .vector_4_f32, .kind = .{ .rc = .sse } },
160382 .unused,
160383 .unused,
160384 .unused,
160385 .unused,
160386 .unused,
160387 .unused,
160388 .unused,
160389 .unused,
160390 .unused,
160391 .unused,
160392 },
160393 .dst_temps = .{ .{ .ref = .src0 }, .unused },
160394 .each = .{ .once = &.{
160395 .{ ._, ._, .movshdup, .tmp0x, .src0x, ._, ._ },
160396 .{ ._, ._ss, .mul, .dst0x, .tmp0x, ._, ._ },
160397 .{ ._, ._ps, .movhl, .tmp0x, .dst0x, ._, ._ },
160398 .{ ._, ._ss, .mul, .dst0x, .tmp0x, ._, ._ },
160399 } },
160308 }, .{160400 }, .{
160309 .required_features = .{ .sse, null, null, null },160401 .required_features = .{ .sse, null, null, null },
160310 .dst_constraints = .{ .{ .float = .dword }, .any },160402 .dst_constraints = .{ .{ .float = .dword }, .any },
...@@ -160327,10 +160419,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160327,10 +160419,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160327 },160419 },
160328 .dst_temps = .{ .{ .ref = .src0 }, .unused },160420 .dst_temps = .{ .{ .ref = .src0 }, .unused },
160329 .each = .{ .once = &.{160421 .each = .{ .once = &.{
160330 .{ ._, ._ps, .xor, .tmp0x, .tmp0x, ._, ._ },160422 .{ ._, ._ps, .mova, .tmp0x, .src0x, ._, ._ },
160423 .{ ._, ._ps, .shuf, .tmp0x, .src0x, .ui(0b01), ._ },
160424 .{ ._, ._ss, .mul, .dst0x, .tmp0x, ._, ._ },
160331 .{ ._, ._ps, .movhl, .tmp0x, .src0x, ._, ._ },160425 .{ ._, ._ps, .movhl, .tmp0x, .src0x, ._, ._ },
160332 .{ ._, ._ss, .mul, .tmp0x, .src0x, ._, ._ },
160333 .{ ._, ._ps, .shuf, .dst0x, .src0x, .ui(0b01), ._ },
160334 .{ ._, ._ss, .mul, .dst0x, .tmp0x, ._, ._ },160426 .{ ._, ._ss, .mul, .dst0x, .tmp0x, ._, ._ },
160335 } },160427 } },
160336 }, .{160428 }, .{
...@@ -160464,9 +160556,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160464,9 +160556,9 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160464 },160556 },
160465 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },160557 .dst_temps = .{ .{ .mut_rc = .{ .ref = .src0, .rc = .sse } }, .unused },
160466 .each = .{ .once = &.{160558 .each = .{ .once = &.{
160467 .{ ._, .v_f128, .extract, .tmp0x, .src0y, .ui(1), ._ },160559 .{ ._, .v_ps, .movhl, .tmp0x, .src0x, .src0x, ._ },
160468 .{ ._, .v_sd, .mul, .tmp0x, .src0x, .tmp0x, ._ },160560 .{ ._, .v_sd, .mul, .tmp0x, .src0x, .tmp0x, ._ },
160469 .{ ._, .v_ps, .movhl, .dst0x, .src0x, .src0x, ._ },160561 .{ ._, .v_f128, .extract, .dst0x, .src0y, .ui(1), ._ },
160470 .{ ._, .v_sd, .mul, .dst0x, .tmp0x, .dst0x, ._ },160562 .{ ._, .v_sd, .mul, .dst0x, .tmp0x, .dst0x, ._ },
160471 } },160563 } },
160472 }, .{160564 }, .{
...@@ -160528,6 +160620,44 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160528,6 +160620,44 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160528 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },160620 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
160529 } },160621 } },
160530 }, .{160622 }, .{
160623 .required_abi = .gnu,
160624 .required_features = .{ .x87, null, null, null },
160625 .dst_constraints = .{ .{ .float = .qword }, .any },
160626 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },
160627 .patterns = &.{
160628 .{ .src = .{ .to_mem, .none, .none } },
160629 },
160630 .extra_temps = .{
160631 .{ .type = .u16, .kind = .mem },
160632 .{ .type = .isize, .kind = .{ .rc = .general_purpose } },
160633 .{ .type = .f64, .kind = .{ .reg = .st7 } },
160634 .unused,
160635 .unused,
160636 .unused,
160637 .unused,
160638 .unused,
160639 .unused,
160640 .unused,
160641 .unused,
160642 },
160643 .dst_temps = .{ .mem, .unused },
160644 .clobbers = .{ .eflags = true },
160645 .each = .{ .once = &.{
160646 .{ ._, .fn_cw, .st, .tmp0w, ._, ._, ._ },
160647 .{ ._, ._, .movzx, .tmp1d, .memd(.tmp0b, 1), ._, ._ },
160648 .{ ._, ._, .@"and", .memd(.tmp0b, 1), .ui(0b111_1_11_10), ._, ._ },
160649 .{ ._, .f_cw, .ld, .tmp0w, ._, ._, ._ },
160650 .{ ._, ._, .mov, .memd(.tmp0b, 1), .tmp1b, ._, ._ },
160651 .{ ._, ._, .mov, .tmp1p, .sia(8, .src0, .sub_unaligned_size), ._, ._ },
160652 .{ ._, .f_, .ld, .mem(.src0q), ._, ._, ._ },
160653 .{ .@"0:", .f_, .mul, .memia(.src0q, .tmp1, .add_unaligned_size), ._, ._, ._ },
160654 .{ ._, ._, .add, .tmp1p, .si(8), ._, ._ },
160655 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
160656 .{ ._, .f_p, .st, .dst0q, ._, ._, ._ },
160657 .{ ._, .f_cw, .ld, .tmp0w, ._, ._, ._ },
160658 } },
160659 }, .{
160660 .required_abi = .msvc,
160531 .required_features = .{ .x87, null, null, null },160661 .required_features = .{ .x87, null, null, null },
160532 .dst_constraints = .{ .{ .float = .qword }, .any },160662 .dst_constraints = .{ .{ .float = .qword }, .any },
160533 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },160663 .src_constraints = .{ .{ .multiple_scalar_float = .{ .of = .qword, .is = .qword } }, .any, .any },
...@@ -160552,13 +160682,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {...@@ -160552,13 +160682,10 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void {
160552 .each = .{ .once = &.{160682 .each = .{ .once = &.{
160553 .{ ._, ._, .mov, .tmp0p, .sia(8, .src0, .sub_unaligned_size), ._, ._ },160683 .{ ._, ._, .mov, .tmp0p, .sia(8, .src0, .sub_unaligned_size), ._, ._ },
160554 .{ ._, .f_, .ld, .mem(.src0q), ._, ._, ._ },160684 .{ ._, .f_, .ld, .mem(.src0q), ._, ._, ._ },
160555 .{ ._, ._mp, .j, .@"1f", ._, ._, ._ },160685 .{ .@"0:", .f_, .mul, .memia(.src0q, .tmp0, .add_unaligned_size), ._, ._, ._ },
160556 .{ .pseudo, .f_cstp, .in, ._, ._, ._, ._ },
160557 .{ .@"0:", .f_, .ld, .dst0q, ._, ._, ._ },
160558 .{ .@"1:", .f_, .mul, .memia(.src0q, .tmp0, .add_unaligned_size), ._, ._, ._ },
160559 .{ ._, ._, .add, .tmp0p, .si(8), ._, ._ },160686 .{ ._, ._, .add, .tmp0p, .si(8), ._, ._ },
160560 .{ ._, .f_p, .st, .dst0q, ._, ._, ._ },
160561 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },160687 .{ ._, ._nc, .j, .@"0b", ._, ._, ._ },
160688 .{ ._, .f_p, .st, .dst0q, ._, ._, ._ },
160562 } },160689 } },
160563 }, .{160690 }, .{
160564 .required_abi = .gnu,160691 .required_abi = .gnu,
test/behavior/x86_64/math.zig+4
...@@ -22,6 +22,10 @@ pub const Sse = if (builtin.cpu.has(.x86, .avx))...@@ -22,6 +22,10 @@ pub const Sse = if (builtin.cpu.has(.x86, .avx))
22else22else
23 @Vector(16, u8);23 @Vector(16, u8);
2424
25pub fn fracBits(comptime Float: type) comptime_int {
26 return std.math.floatFractionalBits(Float);
27}
28
25pub fn Scalar(comptime Type: type) type {29pub fn Scalar(comptime Type: type) type {
26 return switch (@typeInfo(Type)) {30 return switch (@typeInfo(Type)) {
27 else => Type,31 else => Type,
test/behavior/x86_64/unary.zig+46
...@@ -5,6 +5,7 @@ const Compare = math.Compare;...@@ -5,6 +5,7 @@ const Compare = math.Compare;
5const fmax = math.fmax;5const fmax = math.fmax;
6const fmin = math.fmin;6const fmin = math.fmin;
7const Gpr = math.Gpr;7const Gpr = math.Gpr;
8const fracBits = math.fracBits;
8const inf = math.inf;9const inf = math.inf;
9const Log2IntCeil = math.Log2IntCeil;10const Log2IntCeil = math.Log2IntCeil;
10const math = @import("math.zig");11const math = @import("math.zig");
...@@ -4487,34 +4488,65 @@ fn unary(comptime op: anytype, comptime opts: struct {...@@ -4487,34 +4488,65 @@ fn unary(comptime op: anytype, comptime opts: struct {
4487 fn testFloatVectorTypes() !void {4488 fn testFloatVectorTypes() !void {
4488 try testArgs(@Vector(1, f16), undefined);4489 try testArgs(@Vector(1, f16), undefined);
4489 try testArgs(@Vector(2, f16), undefined);4490 try testArgs(@Vector(2, f16), undefined);
4491 try testArgs(@Vector(3, f16), undefined);
4490 try testArgs(@Vector(4, f16), undefined);4492 try testArgs(@Vector(4, f16), undefined);
4493 try testArgs(@Vector(5, f16), undefined);
4494 try testArgs(@Vector(7, f16), undefined);
4491 try testArgs(@Vector(8, f16), undefined);4495 try testArgs(@Vector(8, f16), undefined);
4496 try testArgs(@Vector(9, f16), undefined);
4497 try testArgs(@Vector(15, f16), undefined);
4492 try testArgs(@Vector(16, f16), undefined);4498 try testArgs(@Vector(16, f16), undefined);
4499 try testArgs(@Vector(17, f16), undefined);
4500 try testArgs(@Vector(31, f16), undefined);
4493 try testArgs(@Vector(32, f16), undefined);4501 try testArgs(@Vector(32, f16), undefined);
4502 try testArgs(@Vector(33, f16), undefined);
4503 try testArgs(@Vector(63, f16), undefined);
4494 try testArgs(@Vector(64, f16), undefined);4504 try testArgs(@Vector(64, f16), undefined);
4505 try testArgs(@Vector(65, f16), undefined);
44954506
4496 try testArgs(@Vector(1, f32), undefined);4507 try testArgs(@Vector(1, f32), undefined);
4497 try testArgs(@Vector(2, f32), undefined);4508 try testArgs(@Vector(2, f32), undefined);
4509 try testArgs(@Vector(3, f32), undefined);
4498 try testArgs(@Vector(4, f32), undefined);4510 try testArgs(@Vector(4, f32), undefined);
4511 try testArgs(@Vector(5, f32), undefined);
4512 try testArgs(@Vector(7, f32), undefined);
4499 try testArgs(@Vector(8, f32), undefined);4513 try testArgs(@Vector(8, f32), undefined);
4514 try testArgs(@Vector(9, f32), undefined);
4515 try testArgs(@Vector(15, f32), undefined);
4500 try testArgs(@Vector(16, f32), undefined);4516 try testArgs(@Vector(16, f32), undefined);
4517 try testArgs(@Vector(17, f32), undefined);
4518 try testArgs(@Vector(31, f32), undefined);
4501 try testArgs(@Vector(32, f32), undefined);4519 try testArgs(@Vector(32, f32), undefined);
4520 try testArgs(@Vector(33, f32), undefined);
45024521
4503 try testArgs(@Vector(1, f64), undefined);4522 try testArgs(@Vector(1, f64), undefined);
4504 try testArgs(@Vector(2, f64), undefined);4523 try testArgs(@Vector(2, f64), undefined);
4524 try testArgs(@Vector(3, f64), undefined);
4505 try testArgs(@Vector(4, f64), undefined);4525 try testArgs(@Vector(4, f64), undefined);
4526 try testArgs(@Vector(5, f64), undefined);
4527 try testArgs(@Vector(7, f64), undefined);
4506 try testArgs(@Vector(8, f64), undefined);4528 try testArgs(@Vector(8, f64), undefined);
4529 try testArgs(@Vector(9, f64), undefined);
4530 try testArgs(@Vector(15, f64), undefined);
4507 try testArgs(@Vector(16, f64), undefined);4531 try testArgs(@Vector(16, f64), undefined);
4532 try testArgs(@Vector(17, f64), undefined);
45084533
4509 try testArgs(@Vector(1, f80), undefined);4534 try testArgs(@Vector(1, f80), undefined);
4510 try testArgs(@Vector(2, f80), undefined);4535 try testArgs(@Vector(2, f80), undefined);
4536 try testArgs(@Vector(3, f80), undefined);
4511 try testArgs(@Vector(4, f80), undefined);4537 try testArgs(@Vector(4, f80), undefined);
4538 try testArgs(@Vector(5, f80), undefined);
4539 try testArgs(@Vector(7, f80), undefined);
4512 try testArgs(@Vector(8, f80), undefined);4540 try testArgs(@Vector(8, f80), undefined);
4541 try testArgs(@Vector(9, f80), undefined);
45134542
4514 try testArgs(@Vector(1, f128), undefined);4543 try testArgs(@Vector(1, f128), undefined);
4515 try testArgs(@Vector(2, f128), undefined);4544 try testArgs(@Vector(2, f128), undefined);
4545 try testArgs(@Vector(3, f128), undefined);
4516 try testArgs(@Vector(4, f128), undefined);4546 try testArgs(@Vector(4, f128), undefined);
4547 try testArgs(@Vector(7, f128), undefined);
4517 try testArgs(@Vector(8, f128), undefined);4548 try testArgs(@Vector(8, f128), undefined);
4549 try testArgs(@Vector(9, f128), undefined);
4518 }4550 }
4519 fn testFloatVectors() !void {4551 fn testFloatVectors() !void {
4520 try testArgs(@Vector(1, f16), .{4552 try testArgs(@Vector(1, f16), .{
...@@ -5257,6 +5289,20 @@ test reduceMulOptimized {...@@ -5257,6 +5289,20 @@ test reduceMulOptimized {
5257 try test_reduce_mul_optimized.testFloatVectors();5289 try test_reduce_mul_optimized.testFloatVectors();
5258}5290}
52595291
5292inline fn reduceAddOrder(comptime Type: type, _: Type) @typeInfo(Type).vector.child {
5293 const vector = @typeInfo(Type).vector;
5294 const full_mant_bits = 1 + fracBits(vector.child);
5295 comptime var rhs: Type = @splat(1);
5296 rhs[0] = @exp2(full_mant_bits);
5297 rhs[@as(usize, vector.len) -| 2] = -rhs[0];
5298 rhs[vector.len - 1] = @exp2(-full_mant_bits);
5299 return @reduce(.Add, runtime(Type, rhs));
5300}
5301test reduceAddOrder {
5302 const test_reduce_add_order = unary(reduceAddOrder, .{});
5303 try test_reduce_add_order.testFloatVectorTypes();
5304}
5305
5260inline fn splat(comptime Type: type, rhs: Type) Type {5306inline fn splat(comptime Type: type, rhs: Type) Type {
5261 return @splat(rhs[0]);5307 return @splat(rhs[0]);
5262}5308}