]> gcc.gnu.org Git - gcc.git/commitdiff
rs6000: Eliminate unnecessary byte swaps for duplicated constant vector store
authorHaochen Gui <guihaoc@gcc.gnu.org>
Mon, 24 Jun 2024 05:16:12 +0000 (13:16 +0800)
committerHaochen Gui <guihaoc@gcc.gnu.org>
Mon, 24 Jun 2024 05:17:27 +0000 (13:17 +0800)
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.

gcc/config/rs6000/vsx.md
gcc/testsuite/gcc.target/powerpc/pr113325.c [new file with mode: 0644]

index 7a9c19ac903054c3ec39bb0097334ebf4a4dd5de..48ba262f7e485d2508e61672b9ff89c5feb94332 100644 (file)
   "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 (file)
index 0000000..3ca1fcb
--- /dev/null
@@ -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);
+}
This page took 0.070626 seconds and 5 git commands to generate.