From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1923) id 3EDCB3858C2F; Tue, 23 Jan 2024 20:58:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EDCB3858C2F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706043534; bh=vEB1ph+DA0uIh0DBOGZZI8/v95w76zk/jJ3eLMRN5j4=; h=From:To:Subject:Date:From; b=jdSbdw5S5hcc7SxQPCYD3SaBLkLt1ecmcNY26zioRcXFmmSFMTsQrPg/z6gJCz65a 4XAuOZx/n18vs1DWwOpx3EQdI+6tMHzdFk5YRJAbEz0SsvLDR3g/O0H7aX5ig168yC pKXF9ZMCiz6WMaeFfs9r5ZrcoETgirW6RErqaaqo= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Philipp Tomsich To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/vrull/heads/slp-improvements)] Use an enum to name rearrangement patterns in SLP X-Act-Checkin: gcc X-Git-Author: Manolis Tsamis X-Git-Refname: refs/vendors/vrull/heads/slp-improvements X-Git-Oldrev: f6475f45816bc749c1f2da9deccca5fbbb842427 X-Git-Newrev: ad9480ccfb1f2985f4c9bfebf9ecc5d0741e82e6 Message-Id: <20240123205854.3EDCB3858C2F@sourceware.org> Date: Tue, 23 Jan 2024 20:58:54 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ad9480ccfb1f2985f4c9bfebf9ecc5d0741e82e6 commit ad9480ccfb1f2985f4c9bfebf9ecc5d0741e82e6 Author: Manolis Tsamis 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 &oprnds_info, unsigned group_size) { @@ -1828,59 +1835,59 @@ try_rearrange_oprnd_info (vec &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 &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) {