public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/vrull/heads/slp-improvements)] Use an enum to name rearrangement patterns in SLP Date: Tue, 23 Jan 2024 20:58:54 +0000 (GMT) [thread overview] Message-ID: <20240123205854.3EDCB3858C2F@sourceware.org> (raw) https://gcc.gnu.org/g:ad9480ccfb1f2985f4c9bfebf9ecc5d0741e82e6 commit ad9480ccfb1f2985f4c9bfebf9ecc5d0741e82e6 Author: Manolis Tsamis <manolis.tsamis@vrull.eu> Date: Fri Dec 15 17:19:12 2023 +0100 Use an enum to name rearrangement patterns in SLP Ref #342 Diff: --- gcc/tree-vect-slp.cc | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index f629e4de5d3..732affece3b 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -1820,6 +1820,13 @@ vect_slp_build_two_operator_nodes (slp_tree perm, tree vectype, SLP_TREE_CHILDREN (perm).quick_push (child2); } +enum slp_oprnd_pattern { + SLP_OPRND_PATTERN_NONE, + SLP_OPRND_PATTERN_ABAB, + SLP_OPRND_PATTERN_AABB, + SLP_OPRND_PATTERN_ABBA +}; + static int try_rearrange_oprnd_info (vec<slp_oprnd_info> &oprnds_info, unsigned group_size) { @@ -1828,59 +1835,59 @@ try_rearrange_oprnd_info (vec<slp_oprnd_info> &oprnds_info, unsigned group_size) /* A more generalized version is WIP but this is generic enough anyway. */ if (oprnds_info.length() != 2 || group_size % 4 != 0) - return 0; + return SLP_OPRND_PATTERN_NONE; FOR_EACH_VEC_ELT (oprnds_info, i, oprnd_info) for (unsigned int j = 0; j < group_size; j += 1) if (!oprnd_info->def_stmts[j] || STMT_VINFO_DATA_REF (oprnd_info->def_stmts[j])) - return 0; + return SLP_OPRND_PATTERN_NONE; - int pattern = 0; + int pattern = SLP_OPRND_PATTERN_NONE; FOR_EACH_VEC_ELT (oprnds_info, i, oprnd_info) for (unsigned int j = 0; j < group_size; j += 4) { - int cur_pattern = 0; + int cur_pattern = SLP_OPRND_PATTERN_NONE; /* Check for an ABAB... pattern. */ if ((oprnd_info->def_stmts[j] == oprnd_info->def_stmts[j + 2]) && (oprnd_info->def_stmts[j + 1] == oprnd_info->def_stmts[j + 3]) && (oprnd_info->def_stmts[j] != oprnd_info->def_stmts[j + 1])) - cur_pattern = 1; + cur_pattern = SLP_OPRND_PATTERN_ABAB; /* Check for an AABB... pattern. */ else if ((oprnd_info->def_stmts[j] == oprnd_info->def_stmts[j + 1]) && (oprnd_info->def_stmts[j + 2] == oprnd_info->def_stmts[j + 3]) && (oprnd_info->def_stmts[j] != oprnd_info->def_stmts[j + 2])) - cur_pattern = 2; + cur_pattern = SLP_OPRND_PATTERN_AABB; /* Check for an ABBA... pattern. */ else if ((oprnd_info->def_stmts[j] == oprnd_info->def_stmts[j + 3]) && (oprnd_info->def_stmts[j + 1] == oprnd_info->def_stmts[j + 2]) && (oprnd_info->def_stmts[j] != oprnd_info->def_stmts[j + 1])) - cur_pattern = 3; + cur_pattern = SLP_OPRND_PATTERN_ABBA; /* Unrecognised pattern. */ else - return 0; + return SLP_OPRND_PATTERN_NONE; - if (pattern == 0) + if (pattern == SLP_OPRND_PATTERN_NONE) pattern = cur_pattern; /* Multiple patterns detected. */ else if (cur_pattern != pattern) - return 0; + return SLP_OPRND_PATTERN_NONE; } - gcc_checking_assert (pattern); + gcc_checking_assert (pattern != SLP_OPRND_PATTERN_NONE); if (dump_enabled_p ()) { - if (pattern == 1) + if (pattern == SLP_OPRND_PATTERN_ABAB) dump_printf (MSG_NOTE, "ABAB"); - else if (pattern == 2) + else if (pattern == SLP_OPRND_PATTERN_AABB) dump_printf (MSG_NOTE, "AABB"); - else if (pattern == 3) + else if (pattern == SLP_OPRND_PATTERN_ABBA) dump_printf (MSG_NOTE, "ABBA"); dump_printf (MSG_NOTE, " pattern detected.\n"); } - if (pattern == 1 || pattern == 3) + if (pattern == SLP_OPRND_PATTERN_ABAB || pattern == SLP_OPRND_PATTERN_ABBA) for (unsigned int j = 0; j < group_size; j += 4) { oprnds_info[0]->def_stmts[j+2] = oprnds_info[1]->def_stmts[j]; @@ -1888,7 +1895,7 @@ try_rearrange_oprnd_info (vec<slp_oprnd_info> &oprnds_info, unsigned group_size) oprnds_info[0]->def_stmts[j+3] = oprnds_info[1]->def_stmts[j+1]; oprnds_info[0]->ops[j+3] = oprnds_info[1]->ops[j+1]; } - else if (pattern == 2) + else if (pattern == SLP_OPRND_PATTERN_AABB) for (unsigned int j = 0; j < group_size; j += 4) { /* The ordering here is at least to some extent arbitrary. @@ -2749,7 +2756,7 @@ fail: /* If we applied any rearrangmenets then we need to reconstruct the original elements with an additional permutation layer. */ - if (rearrange_pattern) + if (rearrange_pattern != SLP_OPRND_PATTERN_NONE) { slp_tree one = new _slp_tree; slp_tree two = new _slp_tree; @@ -2766,7 +2773,7 @@ fail: SLP_TREE_REPRESENTATIVE (one) = stmts[0]; SLP_TREE_REPRESENTATIVE (two) = stmts[h]; - if (rearrange_pattern == 1) + if (rearrange_pattern == SLP_OPRND_PATTERN_ABAB) { for (unsigned int j = 0; j < h; j += 2) { @@ -2783,7 +2790,7 @@ fail: SLP_TREE_LANE_PERMUTATION(two).safe_push (std::make_pair (0, h + j + 1)); } } - else if (rearrange_pattern == 2) + else if (rearrange_pattern == SLP_OPRND_PATTERN_AABB) { for (unsigned int j = 0; j < h; j += 2) { @@ -2800,7 +2807,7 @@ fail: SLP_TREE_LANE_PERMUTATION(two).safe_push (std::make_pair (0, h + j + 1)); } } - else if (rearrange_pattern == 3) + else if (rearrange_pattern == SLP_OPRND_PATTERN_ABBA) { for (unsigned int j = 0; j < h; j += 2) {
next reply other threads:[~2024-01-23 20:58 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-23 20:58 Philipp Tomsich [this message] -- strict thread matches above, loose matches on Subject: below -- 2024-01-17 19:15 Philipp Tomsich
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240123205854.3EDCB3858C2F@sourceware.org \ --to=ptomsich@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).