Hi,

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77613 identifies a case
where we fail to remove swaps from a region because it contains a form
of splat that we don't yet recognize.  This patch adds support for splat
insns that have an embedded truncate, such as the vsx_vsplth_di pattern.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
regressions.  Ok for trunk, and eventual backport to 6 and 5 branches?

Thanks,
Bill


[gcc]

2016-09-16  Bill Schmidt  <wschm...@linux.vnet.ibm.com>

        PR target/77613
        * config/rs6000/rs6000.c (rtx_is_swappable_p): Add support for
        splat with truncate.

[gcc/testsuite]

2016-09-16  Bill Schmidt  <wschm...@linux.vnet.ibm.com>

        PR target/77613
        * gcc.target/powerpc/swaps-p8-25.c: New.


Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  (revision 240187)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -39105,6 +39105,11 @@ rtx_is_swappable_p (rtx op, unsigned int *special)
               && GET_MODE_INNER (GET_MODE (op)) == GET_MODE (XEXP (op, 0)))
        /* This catches V2DF and V2DI splat, at a minimum.  */
        return 1;
+      else if (GET_CODE (XEXP (op, 0)) == TRUNCATE
+              && GET_CODE (XEXP (XEXP (op, 0), 0)) == REG
+              && GET_MODE_INNER (GET_MODE (op)) == GET_MODE (XEXP (op, 0)))
+       /* This catches splat of a truncated value.  */
+       return 1;
       else if (GET_CODE (XEXP (op, 0)) == VEC_SELECT)
        /* If the duplicated item is from a select, defer to the select
           processing to see if we can change the lane for the splat.  */
Index: gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c      (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/swaps-p8-25.c      (working copy)
@@ -0,0 +1,18 @@
+/* { dg-do compile { target { powerpc64le-*-* } } } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8 -O3 " } */
+/* { dg-final { scan-assembler "lxvd2x" } } */
+/* { dg-final { scan-assembler "stxvd2x" } } */
+/* { dg-final { scan-assembler-not "xxpermdi" } } */
+
+/* Verify that swap optimization works correctly for a truncating splat.  */
+
+/* Test case to resolve PR77613.  */
+
+void pr77613 (signed short a, signed short *x, signed short *y)
+{
+  unsigned long i;
+
+  for (i = 0; i < 1024; i++)
+    y[i] = a * x[i] + y[i];
+}

Reply via email to