S/390: Enable vrepi constants.
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Wed, 2 Dec 2015 07:55:40 +0000 (07:55 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Wed, 2 Dec 2015 07:55:40 +0000 (07:55 +0000)
gcc/testsuite/ChangeLog:

2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* gcc.target/s390/vector/vec-vrepi-1.c: New test.

gcc/ChangeLog:

2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/s390/constraints.md ("jKK"): New constraint.
* config/s390/s390.c (tm-constrs.h): Include for
satisfies_constraint_*.
(s390_legitimate_constant_p): Allow jKK constants.  Use
satisfies_constraint_* also for the others.
(legitimate_reload_vector_constant_p): Likewise.
(print_operand): Allow h output modifier on vectors.
* config/s390/vector.md ("mov<mode>"): Add vrepi.

From-SVN: r231154

gcc/ChangeLog
gcc/config/s390/constraints.md
gcc/config/s390/s390.c
gcc/config/s390/vector.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/vector/vec-vrepi-1.c [new file with mode: 0644]

index 8b6fdbc9eb4a9369bacb157327afd406180aea13..c5b4fdab3d3e09f6ee7d3d90454d26a25d6091ef 100644 (file)
@@ -1,3 +1,14 @@
+2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * config/s390/constraints.md ("jKK"): New constraint.
+       * config/s390/s390.c (tm-constrs.h): Include for
+       satisfies_constraint_*.
+       (s390_legitimate_constant_p): Allow jKK constants.  Use
+       satisfies_constraint_* also for the others.
+       (legitimate_reload_vector_constant_p): Likewise.
+       (print_operand): Allow h output modifier on vectors.
+       * config/s390/vector.md ("mov<mode>"): Add vrepi.
+
 2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * config/s390/vector.md ("*vec_splats<mode>"): Fix constraint
index 66d4acecdb3524f21993a59381519a4565f470a6..1dab92ac66ab14d3188be30caa9daa361581808b 100644 (file)
@@ -34,6 +34,8 @@
 ;;         jm1: constant scalar or vector with all bits set
 ;;         jxx: contiguous bitmask of 0 or 1 in all vector elements
 ;;         jyy: constant consisting of byte chunks being either 0 or 0xff
+;;         jKK: constant vector with all elements having the same value and
+;;              matching K constraint
 ;;    t -- Access registers 36 and 37.
 ;;    v -- Vector registers v0-v31.
 ;;    C -- A signed 8-bit constant (-128..127)
   "FP_REGS"
   "Floating point registers")
 
-(define_constraint "j00"
-  "Zero scalar or vector constant"
-  (match_test "op == CONST0_RTX (GET_MODE (op))"))
-
-(define_constraint "jm1"
-  "All one bit scalar or vector constant"
-  (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
-
-(define_constraint "jxx"
-  "@internal"
-  (and (match_code "const_vector")
-       (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
-
-(define_constraint "jyy"
-  "@internal"
-  (and (match_code "const_vector")
-       (match_test "s390_bytemask_vector_p (op, NULL)")))
 
 (define_register_constraint "t"
   "ACCESS_REGS"
        (match_test "s390_O_constraint_str ('n', ival)")))
 
 
+;;
+;; Vector constraints follow.
+;;
+
+(define_constraint "j00"
+  "Zero scalar or vector constant"
+  (match_test "op == CONST0_RTX (GET_MODE (op))"))
+
+(define_constraint "jm1"
+  "All one bit scalar or vector constant"
+  (match_test "op == CONSTM1_RTX (GET_MODE (op))"))
+
+(define_constraint "jxx"
+  "@internal"
+  (and (match_code "const_vector")
+       (match_test "s390_contiguous_bitmask_vector_p (op, NULL, NULL)")))
+
+(define_constraint "jyy"
+  "@internal"
+  (and (match_code "const_vector")
+       (match_test "s390_bytemask_vector_p (op, NULL)")))
+
+(define_constraint "jKK"
+  "@internal"
+  (and (and (match_code "const_vector")
+           (match_test "const_vec_duplicate_p (op)"))
+       (match_test "satisfies_constraint_K (XVECEXP (op, 0, 0))")))
 
 
 ;;
index 5a7406c65ce702c23954eb4769a99b4e48b09c80..73465ef21e4402410a73013eaa372db2b0aa2c98 100644 (file)
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "rtl-iter.h"
 #include "intl.h"
+#include "tm-constrs.h"
 
 /* This file should be included last.  */
 #include "target-def.h"
@@ -3643,9 +3644,11 @@ s390_legitimate_constant_p (machine_mode mode, rtx op)
       if (GET_MODE_SIZE (mode) != 16)
        return 0;
 
-      if (!const0_operand (op, mode)
-         && !s390_contiguous_bitmask_vector_p (op, NULL, NULL)
-         && !s390_bytemask_vector_p (op, NULL))
+      if (!satisfies_constraint_j00 (op)
+         && !satisfies_constraint_jm1 (op)
+         && !satisfies_constraint_jKK (op)
+         && !satisfies_constraint_jxx (op)
+         && !satisfies_constraint_jyy (op))
        return 0;
     }
 
@@ -3826,14 +3829,12 @@ legitimate_reload_fp_constant_p (rtx op)
 static bool
 legitimate_reload_vector_constant_p (rtx op)
 {
-  /* FIXME: Support constant vectors with all the same 16 bit unsigned
-     operands.  These can be loaded with vrepi.  */
-
   if (TARGET_VX && GET_MODE_SIZE (GET_MODE (op)) == 16
-      && (const0_operand (op, GET_MODE (op))
-         || constm1_operand (op, GET_MODE (op))
-         || s390_contiguous_bitmask_vector_p (op, NULL, NULL)
-         || s390_bytemask_vector_p (op, NULL)))
+      && (satisfies_constraint_j00 (op)
+         || satisfies_constraint_jm1 (op)
+         || satisfies_constraint_jKK (op)
+         || satisfies_constraint_jxx (op)
+         || satisfies_constraint_jyy (op)))
     return true;
 
   return false;
@@ -7132,6 +7133,11 @@ print_operand (FILE *file, rtx x, int code)
     case CONST_VECTOR:
       switch (code)
        {
+       case 'h':
+         gcc_assert (const_vec_duplicate_p (x));
+         fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+                  ((INTVAL (XVECEXP (x, 0, 0)) & 0xffff) ^ 0x8000) - 0x8000);
+         break;
        case 'e':
        case 's':
          {
index d8b9b07a24af847d8a641dd0209d31d188b3a0b6..9c1e6a6bd0ea36cc89b87f14c8447685695840d4 100644 (file)
 
 ; Full HW vector size moves
 (define_insn "mov<mode>"
-  [(set (match_operand:V_128 0 "nonimmediate_operand" "=v, v,QR,  v,  v,  v,  v,v,d")
-       (match_operand:V_128 1 "general_operand"      " v,QR, v,j00,jm1,jyy,jxx,d,v"))]
+  [(set (match_operand:V_128 0 "nonimmediate_operand" "=v, v,QR,  v,  v,  v,  v,  v,v,d")
+       (match_operand:V_128 1 "general_operand"      " v,QR, v,j00,jm1,jyy,jxx,jKK,d,v"))]
   "TARGET_VX"
   "@
    vlr\t%v0,%v1
    vone\t%v0
    vgbm\t%v0,%t1
    vgm<bhfgq>\t%v0,%s1,%e1
+   vrepi<bhfgq>\t%v0,%h1
    vlvgp\t%v0,%1,%N1
    #"
-  [(set_attr "op_type" "VRR,VRX,VRX,VRI,VRI,VRI,VRI,VRR,*")])
+  [(set_attr "op_type" "VRR,VRX,VRX,VRI,VRI,VRI,VRI,VRI,VRR,*")])
 
 (define_split
   [(set (match_operand:V_128 0 "register_operand" "")
index 79e459603e2a05d8284f909ea6fa80db2a0930b1..ea09cb1640a24e492a0a289f8dd24cc9acc59034 100644 (file)
@@ -1,3 +1,7 @@
+2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * gcc.target/s390/vector/vec-vrepi-1.c: New test.
+
 2015-12-02  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * gcc.target/s390/zvector/vec-splat-1.c: New test.
diff --git a/gcc/testsuite/gcc.target/s390/vector/vec-vrepi-1.c b/gcc/testsuite/gcc.target/s390/vector/vec-vrepi-1.c
new file mode 100644 (file)
index 0000000..27bf39e
--- /dev/null
@@ -0,0 +1,58 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -mzarch -march=z13 --save-temps" } */
+/* { dg-require-effective-target vector } */
+
+typedef unsigned char     uv16qi __attribute__((vector_size(16)));
+typedef unsigned short     uv8hi __attribute__((vector_size(16)));
+typedef unsigned int       uv4si __attribute__((vector_size(16)));
+typedef unsigned long long uv2di __attribute__((vector_size(16)));
+
+uv2di __attribute__((noinline))
+foo1 ()
+{
+  return (uv2di){ 0x7f0f, 0x7f0f };
+}
+/* { dg-final { scan-assembler-times "vrepig\t%v24,32527" 1 } } */
+
+uv4si __attribute__((noinline))
+foo2 ()
+{
+  return (uv4si){ 0x7f0f, 0x7f0f, 0x7f0f, 0x7f0f };
+}
+/* { dg-final { scan-assembler-times "vrepif\t%v24,32527" 1 } } */
+
+uv8hi __attribute__((noinline))
+foo3 ()
+{
+  return (uv8hi){ 0x7f0f, 0x7f0f, 0x7f0f, 0x7f0f,
+      0x7f0f, 0x7f0f, 0x7f0f, 0x7f0f };
+}
+/* { dg-final { scan-assembler-times "vrepih\t%v24,32527" 1 } } */
+
+uv16qi __attribute__((noinline))
+foo4 ()
+{
+  return (uv16qi){ 0x77, 0x77, 0x77, 0x77,
+      0x77, 0x77, 0x77, 0x77,
+      0x77, 0x77, 0x77, 0x77,
+      0x77, 0x77, 0x77, 0x77 };
+}
+/* { dg-final { scan-assembler-times "vrepib\t%v24,119" 1 } } */
+
+int
+main ()
+{
+  if (foo1()[1] != 0x7f0f)
+    __builtin_abort ();
+
+  if (foo2()[1] != 0x7f0f)
+    __builtin_abort ();
+
+  if (foo3()[1] != 0x7f0f)
+    __builtin_abort ();
+
+  if (foo4()[1] != 0x77)
+    __builtin_abort ();
+
+  return 0;
+}