public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/vrull/heads/slp-improvements)] Use an enum to name rearrangement patterns in SLP
@ 2024-01-17 19:15 Philipp Tomsich
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Tomsich @ 2024-01-17 19:15 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:54ff9f83f1de7952df6f973b736934dc6379d837
commit 54ff9f83f1de7952df6f973b736934dc6379d837
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 c630ce5bbe0..81ccbaeab1c 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)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc(refs/vendors/vrull/heads/slp-improvements)] Use an enum to name rearrangement patterns in SLP
@ 2024-01-23 20:58 Philipp Tomsich
0 siblings, 0 replies; 2+ messages in thread
From: Philipp Tomsich @ 2024-01-23 20:58 UTC (permalink / raw)
To: gcc-cvs
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)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-23 20:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 19:15 [gcc(refs/vendors/vrull/heads/slp-improvements)] Use an enum to name rearrangement patterns in SLP Philipp Tomsich
2024-01-23 20:58 Philipp Tomsich
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).