public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-207] [SVE] Fold svrev(svrev(v)) to v.
@ 2023-04-24 19:46 Prathamesh Kulkarni
0 siblings, 0 replies; only message in thread
From: Prathamesh Kulkarni @ 2023-04-24 19:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f0eabc52c9a2d3da0bfc201da7a5c1658b76e9a4
commit r14-207-gf0eabc52c9a2d3da0bfc201da7a5c1658b76e9a4
Author: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Date: Tue Apr 25 01:12:28 2023 +0530
[SVE] Fold svrev(svrev(v)) to v.
gcc/ChangeLog:
* tree-ssa-forwprop.cc (is_combined_permutation_identity): Try to
simplify two successive VEC_PERM_EXPRs with same VLA mask,
where mask chooses elements in reverse order.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/acle/general/rev-1.c: New test.
Diff:
---
.../gcc.target/aarch64/sve/acle/general/rev-1.c | 12 ++++++++++++
gcc/tree-ssa-forwprop.cc | 21 +++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/rev-1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/rev-1.c
new file mode 100644
index 00000000000..e57ee67d716
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/rev-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+
+#include <arm_sve.h>
+
+svint32_t f(svint32_t v)
+{
+ return svrev_s32 (svrev_s32 (v));
+}
+
+/* { dg-final { scan-tree-dump "return v_1\\(D\\)" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "VEC_PERM_EXPR" "optimized" } } */
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 9b567440ba4..9dc67b5309c 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -2541,6 +2541,27 @@ is_combined_permutation_identity (tree mask1, tree mask2)
gcc_checking_assert (TREE_CODE (mask1) == VECTOR_CST
&& TREE_CODE (mask2) == VECTOR_CST);
+
+ /* For VLA masks, check for the following pattern:
+ v1 = VEC_PERM_EXPR (v0, ..., mask1)
+ v2 = VEC_PERM_EXPR (v1, ..., mask2)
+ -->
+ v2 = v0
+ if mask1 == mask2 == {nelts - 1, nelts - 2, ...}. */
+
+ if (operand_equal_p (mask1, mask2, 0)
+ && !VECTOR_CST_NELTS (mask1).is_constant ())
+ {
+ vec_perm_builder builder;
+ if (tree_to_vec_perm_builder (&builder, mask1))
+ {
+ poly_uint64 nelts = TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask1));
+ vec_perm_indices sel (builder, 1, nelts);
+ if (sel.series_p (0, 1, nelts - 1, -1))
+ return 1;
+ }
+ }
+
mask = fold_ternary (VEC_PERM_EXPR, TREE_TYPE (mask1), mask1, mask1, mask2);
if (mask == NULL_TREE || TREE_CODE (mask) != VECTOR_CST)
return 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-24 19:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-24 19:46 [gcc r14-207] [SVE] Fold svrev(svrev(v)) to v Prathamesh Kulkarni
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).