Message ID | 8306df2a-775a-6162-bcc8-77e808f8ec1d@linux.ibm.com |
---|---|
State | New |
Headers | show |
Series | [rs6000] optimization for long long and double vec_reve [PR100868] | expand |
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
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 } } */