[gcc r15-1576] rs6000: Eliminate unnecessary byte swaps for duplicated constant vector store
HaoChen Gui
guihaoc@gcc.gnu.org
Mon Jun 24 05:18:39 GMT 2024
https://gcc.gnu.org/g:6274f10318d05311f31147c895f76a01aec37830
commit r15-1576-g6274f10318d05311f31147c895f76a01aec37830
Author: Haochen Gui <guihaoc@gcc.gnu.org>
Date: Mon Jun 24 13:16:12 2024 +0800
rs6000: Eliminate unnecessary byte swaps for duplicated constant vector store
gcc/
PR target/113325
* config/rs6000/vsx.md (vsx_stxvd2x4_le_const_<mode>): New.
gcc/testsuite/
PR target/113325
* gcc.target/powerpc/pr113325.c: New.
Diff:
---
gcc/config/rs6000/vsx.md | 25 +++++++++++++++++++++++++
gcc/testsuite/gcc.target/powerpc/pr113325.c | 9 +++++++++
2 files changed, 34 insertions(+)
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 7a9c19ac903..48ba262f7e4 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -3368,6 +3368,31 @@
"stxvd2x %x1,%y0"
[(set_attr "type" "vecstore")])
+(define_insn_and_split "vsx_stxvd2x4_le_const_<mode>"
+ [(set (match_operand:VSX_W 0 "memory_operand" "=Z")
+ (match_operand:VSX_W 1 "immediate_operand" "W"))]
+ "!BYTES_BIG_ENDIAN
+ && VECTOR_MEM_VSX_P (<MODE>mode)
+ && !TARGET_P9_VECTOR
+ && const_vec_duplicate_p (operands[1])
+ && can_create_pseudo_p ()"
+ "#"
+ "&& 1"
+ [(set (match_dup 2)
+ (match_dup 1))
+ (set (match_dup 0)
+ (vec_select:VSX_W
+ (match_dup 2)
+ (parallel [(const_int 2) (const_int 3)
+ (const_int 0) (const_int 1)])))]
+{
+ /* Here all the constants must be loaded without memory. */
+ gcc_assert (easy_altivec_constant (operands[1], <MODE>mode));
+ operands[2] = gen_reg_rtx (<MODE>mode);
+}
+ [(set_attr "type" "vecstore")
+ (set_attr "length" "8")])
+
(define_insn "*vsx_stxvd2x8_le_V8HI"
[(set (match_operand:V8HI 0 "memory_operand" "=Z")
(vec_select:V8HI
diff --git a/gcc/testsuite/gcc.target/powerpc/pr113325.c b/gcc/testsuite/gcc.target/powerpc/pr113325.c
new file mode 100644
index 00000000000..3ca1fcbc9ba
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr113325.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power8 -mvsx" } */
+/* { dg-require-effective-target powerpc_vsx } */
+/* { dg-final { scan-assembler-not {\mxxpermdi\M} } } */
+
+void* foo (void* s1)
+{
+ return __builtin_memset (s1, 0, 32);
+}
More information about the Gcc-cvs
mailing list