public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3350] MATCH: [PR111002] Sink view_convert for vec_cond
@ 2023-08-21 7:45 Andrew Pinski
0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2023-08-21 7:45 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:47b833a9abe19d862a773d20dd6f961dcf811a11
commit r14-3350-g47b833a9abe19d862a773d20dd6f961dcf811a11
Author: Andrew Pinski <apinski@marvell.com>
Date: Sun Aug 20 17:22:27 2023 -0700
MATCH: [PR111002] Sink view_convert for vec_cond
Like convert we can sink view_convert into vec_cond but
we can only do it if the element types are nop_conversions.
This is to allow conversion between signed and unsigned types only.
Rather than between integer and float types which mess up the vec_cond
so that isel does not understand `a?-1:0` is still that.
OK? Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu.
PR tree-optimization/111002
gcc/ChangeLog:
* match.pd (view_convert(vec_cond(a,b,c))): New pattern.
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/sve/cond_convert_8.c: New test.
Diff:
---
gcc/match.pd | 9 +++++++++
.../gcc.target/aarch64/sve/cond_convert_8.c | 22 ++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/gcc/match.pd b/gcc/match.pd
index d5c731e86d04..86fdc606a797 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4712,6 +4712,15 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& types_match (TREE_TYPE (@0), truth_type_for (type)))
(vec_cond @0 (convert! @1) (convert! @2))))
+/* Likewise for view_convert of nop_conversions. */
+(simplify
+ (view_convert (vec_cond:s @0 @1 @2))
+ (if (VECTOR_TYPE_P (type) && VECTOR_TYPE_P (TREE_TYPE (@1))
+ && known_eq (TYPE_VECTOR_SUBPARTS (type),
+ TYPE_VECTOR_SUBPARTS (TREE_TYPE (@1)))
+ && tree_nop_conversion_p (TREE_TYPE (type), TREE_TYPE (TREE_TYPE (@1))))
+ (vec_cond @0 (view_convert! @1) (view_convert! @2))))
+
/* Sink binary operation to branches, but only if we can fold it. */
(for op (tcc_comparison plus minus mult bit_and bit_ior bit_xor
lshift rshift rdiv trunc_div ceil_div floor_div round_div
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cond_convert_8.c b/gcc/testsuite/gcc.target/aarch64/sve/cond_convert_8.c
new file mode 100644
index 000000000000..d8b96e5fcfbd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/cond_convert_8.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -moverride=sve_width=256 -fdump-tree-optimized" } */
+/* PR tree-optimization/111002 */
+
+/* We should be able to remove the neg. */
+
+void __attribute__ ((noipa))
+f (int *__restrict r,
+ int *__restrict a,
+ short *__restrict pred)
+{
+ for (int i = 0; i < 1024; ++i)
+ r[i] = pred[i] != 0 ? -1 : 0;
+}
+
+
+/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.h, p[0-7]+/z, #-1} 1 } } */
+/* { dg-final { scan-assembler-not {\tmov\tz[0-9]+\.[hs], p[0-7]+/z, #1} } } */
+
+/* { dg-final { scan-tree-dump-not "VIEW_CONVERT_EXPR " "optimized" } } */
+/* { dg-final { scan-tree-dump-not " = -" "optimized" } } */
+/* { dg-final { scan-tree-dump-not " = \\\(vector" "optimized" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-21 7:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21 7:45 [gcc r14-3350] MATCH: [PR111002] Sink view_convert for vec_cond Andrew Pinski
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).