This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Abort in output_vec_const_move





Hello,
      we have an abort () in output_vec_const_move, when
compiling testcase below. Problem is, that output_vec_const_move
and easy_vector_constant_add_self are not consistent. Propose
patch appended here.  Bootstrap / regtest ongoing.

OK to commit ? Also gcc-3.4, since it's a regression ?

      regards, Hartmut Penner


testsuite/ChangeLog

 2004-03-22  Hartmut Penner  <hpenner@de.ibm.com>

      * gcc.dg/altivec-11.c: Extend test for more valid cases.

gcc/ChangeLog

 2004-03-22  Hartmut Penner  <hpenner@de.ibm.com>

      * config/rs6000/rs6000.c (output_vec_const_move):
      Find all cases of EASY_VECTOR_15_ADD_SELF.
      (easy_vector_constant_add_self): Accept
      all vector constant loadable by vsplt* and vadd*.
      * config/rs6000/altivec.md (movv4si): Change to
      emit move insn with halfed vector constant.

Index: gcc/config/rs6000/altivec.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/altivec.md,v
retrieving revision 1.16
diff -u -p -r1.16 altivec.md
--- gcc/config/rs6000/altivec.md    11 Feb 2004 14:30:13 -0000    1.16
+++ gcc/config/rs6000/altivec.md    22 Mar 2004 07:53:28 -0000
@@ -124,13 +124,22 @@
   [(set (match_operand:V4SI 0 "altivec_register_operand" "")
      (match_operand:V4SI 1 "easy_vector_constant_add_self" ""))]
   "TARGET_ALTIVEC && reload_completed"
-  [(set (match_dup 0)
-     (unspec:V4SI [(match_dup 3)] UNSPEC_VSPLTISW))
+  [(set (match_dup 0) (match_dup 3))
    (set (match_dup 0)
      (plus:V4SI (match_dup 0)
               (match_dup 0)))]
   "
-{ operands[3] = GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], 0)) >> 1); }")
+{
+  int i, units;
+  rtvec v;
+  units = GET_MODE_NUNITS (GET_MODE (operands[1]));
+  v = rtvec_alloc (units);
+
+  for (i = 0; i < units; i++)
+    RTVEC_ELT (v, i) =
+      GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], i)) >> 1);
+  operands[3] = gen_rtx_raw_CONST_VECTOR (GET_MODE (operands[1]), v);
+}")

 (define_expand "movv8hi"
   [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
@@ -172,13 +181,22 @@
   [(set (match_operand:V8HI 0 "altivec_register_operand" "")
      (match_operand:V8HI 1 "easy_vector_constant_add_self" ""))]
   "TARGET_ALTIVEC && reload_completed"
-  [(set (match_dup 0)
-     (unspec:V8HI [(match_dup 3)] UNSPEC_VSPLTISH))
+  [(set (match_dup 0) (match_dup 3))
    (set (match_dup 0)
      (plus:V8HI (match_dup 0)
               (match_dup 0)))]
   "
-{ operands[3] = GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], 0)) >> 1); }")
+{
+  int i, units;
+  rtvec v;
+  units = GET_MODE_NUNITS (GET_MODE (operands[1]));
+  v = rtvec_alloc (units);
+
+  for (i = 0; i < units; i++)
+    RTVEC_ELT (v, i) =
+      GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], i)) >> 1);
+  operands[3] = gen_rtx_raw_CONST_VECTOR (GET_MODE (operands[1]), v);
+}")

 (define_expand "movv16qi"
   [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
@@ -220,13 +238,22 @@
   [(set (match_operand:V16QI 0 "altivec_register_operand" "")
      (match_operand:V16QI 1 "easy_vector_constant_add_self" ""))]
   "TARGET_ALTIVEC && reload_completed"
-  [(set (match_dup 0)
-     (unspec:V16QI [(match_dup 3)] UNSPEC_VSPLTISB))
+  [(set (match_dup 0) (match_dup 3))
    (set (match_dup 0)
      (plus:V16QI (match_dup 0)
               (match_dup 0)))]
   "
-{ operands[3] = GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], 0)) >> 1); }")
+{
+  int i, units;
+  rtvec v;
+  units = GET_MODE_NUNITS (GET_MODE (operands[1]));
+  v = rtvec_alloc (units);
+
+  for (i = 0; i < units; i++)
+    RTVEC_ELT (v, i) =
+      GEN_INT (INTVAL (CONST_VECTOR_ELT (operands[1], i)) >> 1);
+  operands[3] = gen_rtx_raw_CONST_VECTOR (GET_MODE (operands[1]), v);
+}")

 (define_expand "movv4sf"
   [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.613
diff -u -p -r1.613 rs6000.c
--- gcc/config/rs6000/rs6000.c      20 Mar 2004 02:56:52 -0000    1.613
+++ gcc/config/rs6000/rs6000.c      22 Mar 2004 07:53:36 -0000
@@ -1756,7 +1756,28 @@ easy_vector_constant_add_self (rtx op, e

   cst = INTVAL (CONST_VECTOR_ELT (op, 0));

-  return TARGET_ALTIVEC && EASY_VECTOR_15_ADD_SELF (cst, op, mode);
+  if (TARGET_ALTIVEC)
+    switch (mode)
+      {
+      case V4SImode:
+     if (EASY_VECTOR_15_ADD_SELF (cst, op, mode))
+       return 1;
+     if ((cst & 0xffff) != ((cst >> 16) & 0xffff))
+       break;
+     cst = cst >> 16;
+      case V8HImode:
+     if (EASY_VECTOR_15_ADD_SELF (cst, op, mode))
+       return 1;
+     if ((cst & 0xff) != ((cst >> 8) & 0xff))
+       break;
+     cst = cst >> 8;
+      case V16QImode:
+     if (EASY_VECTOR_15_ADD_SELF (cst, op, mode))
+       return 1;
+      default:
+     break;
+      }
+  return 0;
 }

 const char *
@@ -1790,6 +1811,8 @@ output_vec_const_move (rtx *operands)
              operands[1] = GEN_INT (cst);
              return "vspltisw %0,%1";
            }
+           else if (EASY_VECTOR_15_ADD_SELF (cst, vec, mode))
+           return "#";
            cst = cst >> 16;
          case V8HImode:
            if (EASY_VECTOR_15 (cst, vec, mode))
@@ -1797,6 +1820,8 @@ output_vec_const_move (rtx *operands)
              operands[1] = GEN_INT (cst);
              return "vspltish %0,%1";
            }
+           else if (EASY_VECTOR_15_ADD_SELF (cst, vec, mode))
+           return "#";
            cst = cst >> 8;
          case V16QImode:
            if (EASY_VECTOR_15 (cst, vec, mode))
@@ -1804,6 +1829,8 @@ output_vec_const_move (rtx *operands)
              operands[1] = GEN_INT (cst);
              return "vspltisb %0,%1";
            }
+           else if (EASY_VECTOR_15_ADD_SELF (cst, vec, mode))
+           return "#";
          default:
            abort ();
          }
Index: gcc/testsuite/gcc.dg/altivec-11.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/altivec-11.c,v
retrieving revision 1.1
diff -u -p -r1.1 altivec-11.c
--- gcc/testsuite/gcc.dg/altivec-11.c     8 Jan 2004 07:27:09 -0000     1.1
+++ gcc/testsuite/gcc.dg/altivec-11.c     22 Mar 2004 07:53:26 -0000
@@ -22,6 +22,10 @@ bar (void)
   foo ((vector int) {0x1010101, 0x1010101, 0x1010101, 0x1010101});
   foo ((vector int) {0xf0f0f0f, 0xf0f0f0f, 0xf0f0f0f, 0xf0f0f0f});
   foo ((vector int) {0xf0f0f0f0, 0xf0f0f0f0, 0xf0f0f0f0, 0xf0f0f0f0});
+  foo ((vector int) {0x10101010, 0x10101010, 0x10101010, 0x10101010});
+  foo ((vector int) {0x1e1e1e1e, 0x1e1e1e1e, 0x1e1e1e1e, 0x1e1e1e1e});
+  foo ((vector int) {0x100010, 0x100010, 0x100010, 0x100010});
+  foo ((vector int) {0x1e001e, 0x1e001e, 0x1e001e, 0x1e001e});
   foo ((vector int) {0x10, 0x10, 0x10, 0x10});
   foo ((vector int) {0x1e, 0x1e, 0x1e, 0x1e});

@@ -33,6 +37,10 @@ bar (void)
                         0xf0f0, 0xf0f0, 0xf0f0, 0xf0f0});
   foo_s ((vector short int) {0xf0f, 0xf0f, 0xf0f, 0xf0f,
                         0xf0f, 0xf0f, 0xf0f, 0xf0f});
+  foo_s ((vector short int) {0x1010, 0x1010, 0x1010, 0x1010,
+                        0x1010, 0x1010, 0x1010, 0x1010});
+  foo_s ((vector short int) {0x1e1e, 0x1e1e, 0x1e1e, 0x1e1e,
+                        0x1e1e, 0x1e1e, 0x1e1e, 0x1e1e});

   foo_c ((vector char) {0, 0, 0, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 0});
@@ -42,4 +50,9 @@ bar (void)
                    15, 15, 15, 15, 15, 15, 15, 15});
   foo_c ((vector char) {-16, -16, -16, -16, -16, -16, -16, -16,
                    -16, -16, -16, -16, -16, -16, -16, -16});
+  foo_c ((vector char) {16, 16, 16, 16, 16, 16, 16, 16,
+                   16, 16, 16, 16, 16, 16, 16, 16});
+  foo_c ((vector char) {30, 30, 30, 30, 30, 30, 30, 30,
+                   30, 30, 30, 30, 30, 30, 30, 30});
+
 }




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]