* [PATCH, rs6000] optimization for long long and double vec_reve [PR100868]
@ 2021-09-06 6:10 HAO CHEN GUI
2021-09-06 22:40 ` Segher Boessenkool
0 siblings, 1 reply; 2+ messages in thread
From: HAO CHEN GUI @ 2021-09-06 6:10 UTC (permalink / raw)
To: gcc-patches; +Cc: Segher Boessenkool, Bill Schmidt
Hi
The patch optimized expansion for long long or double vec_reve builtin.
Bootstrapped and tested on powerpc64le-linux with no regressions.
Is this okay for trunk? Any recommendations? Thanks a lot.
ChangeLog
2021-09-06 Haochen Gui <guihaoc@linux.ibm.com>
gcc/
* config/rs6000/altivec.md (altivec_vreve<mode>2):
Modify the expansion when number of elements is 2.
gcc/testsuite/
* gcc.target/powerpc/vec_reve.c: New test.
patch.diff
diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index 1351dafbc41..96e71979fbd 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -4063,6 +4063,13 @@ (define_expand "altivec_vreve<mode>2"
size = GET_MODE_UNIT_SIZE (<MODE>mode);
num_elements = GET_MODE_NUNITS (<MODE>mode);
+ if (num_elements == 2)
+ {
+ emit_insn (gen_vsx_xxpermdi_<mode> (operands[0], operands[1],
+ operands[1], GEN_INT (2)));
+ DONE;
+ }
+
for (j = 0; j < num_elements; j++)
for (i = 0; i < size; i++)
RTVEC_ELT (v, i + j * size)
diff --git a/gcc/testsuite/gcc.target/powerpc/vec_reve.c
b/gcc/testsuite/gcc.target/powerpc/vec_reve.c
new file mode 100644
index 00000000000..d86ce11ba91
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vec_reve.c
@@ -0,0 +1,17 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-O2 -maltivec" } */
+
+#include <altivec.h>
+
+vector double foo1 (vector double a)
+{
+ return vec_reve (a);
+}
+
+vector long long foo2 (vector long long a)
+{
+ return vec_reve (a);
+}
+
+/* { dg-final { scan-assembler-times {\mxxpermdi\M} 2 } } */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH, rs6000] optimization for long long and double vec_reve [PR100868]
2021-09-06 6:10 [PATCH, rs6000] optimization for long long and double vec_reve [PR100868] HAO CHEN GUI
@ 2021-09-06 22:40 ` Segher Boessenkool
0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2021-09-06 22:40 UTC (permalink / raw)
To: HAO CHEN GUI; +Cc: gcc-patches, Bill Schmidt
Hi!
On Mon, Sep 06, 2021 at 02:10:58PM +0800, HAO CHEN GUI wrote:
> The patch optimized expansion for long long or double vec_reve builtin.
>
> Bootstrapped and tested on powerpc64le-linux with no regressions.
> Is this okay for trunk? Any recommendations? Thanks a lot.
In the future, please say something about what you changed, something
about the new code?
"Use xxswapd instead of <whatever we did before>" or even "Use xxswapd".
It doesn't have to be long, but something to guide the reader helps a
lot :-)
> * config/rs6000/altivec.md (altivec_vreve<mode>2):
> Modify the expansion when number of elements is 2.
* config/rs6000/altivec.md (altivec_vreve<mode>2): Modify the expansion
when num_elements is 2.
But "Modify" does not say what you changed it to. So something like
* config/rs6000/altivec.md (altivec_vreve<mode>2): Use xxswapd if
num_elements is 2.
But, there are multiple patterns with that name. So this would be
* config/rs6000/altivec.md (altivec_vreve<mode>2 for VEC_A): Use xxswapd
if num_elements is 2.
That check is a bit nasty, so maybe you should just split this pattern
into one for VEC_K and one for VEC_64?
> --- a/gcc/config/rs6000/altivec.md
> +++ b/gcc/config/rs6000/altivec.md
> @@ -4063,6 +4063,13 @@ (define_expand "altivec_vreve<mode>2"
> size = GET_MODE_UNIT_SIZE (<MODE>mode);
> num_elements = GET_MODE_NUNITS (<MODE>mode);
>
> + if (num_elements == 2)
> + {
> + emit_insn (gen_vsx_xxpermdi_<mode> (operands[0], operands[1],
> + operands[1], GEN_INT (2)));
> + DONE;
> + }
emit_insn (gen_xxswapd_<mode> (operands[0], operands[1]));
If this doesn't compile like this, it will need some "parameterized
names" magic (for xxswapd), a bit more work (but one-time work, and it
is worth it).
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/vec_reve.c
> @@ -0,0 +1,17 @@
> +/* { dg-do compile { target { powerpc*-*-* } } } */
That is the only allowed target in gcc.target/powerpc anyway. Just
write
/* { dg-do compile } */
and nothing more (this (compile) is the default as well, you can just
leave it out completely if you want).
Finally: should whatever the old code generated have been optimised
better?
Segher
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-06 22:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 6:10 [PATCH, rs6000] optimization for long long and double vec_reve [PR100868] HAO CHEN GUI
2021-09-06 22:40 ` Segher Boessenkool
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).