OSDN Git Service

Add CONST1_RTX (vector mode) support.
authorwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Sep 2004 01:49:40 +0000 (01:49 +0000)
committerwilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 11 Sep 2004 01:49:40 +0000 (01:49 +0000)
* emit-rtl.c (gen_const_vector): Renamed from gen_const_vector_0.
Add integer argument named constant.  Use const_tiny_rtx instead of
CONST0_RTX.
(gen_rtx_CONST_VECTOR): Rewrite to handle checks for both CONST0_RTX
and CONST1_RTX.
(init_emit_once): Fix users of gen_const_vector.  Set CONST1_RTX for
vector types.
* expr.c (const_vector_from_tree): Call gen_rtx_CONST_VECTOR instead
of gen_rtx_raw_CONST_VECTOR.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87337 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/emit-rtl.c
gcc/expr.c

index f5aaba3..8088d9f 100644 (file)
@@ -1,3 +1,15 @@
+2004-09-10  James E Wilson  <wilson@specifixinc.com>
+
+       * emit-rtl.c (gen_const_vector): Renamed from gen_const_vector_0.
+       Add integer argument named constant.  Use const_tiny_rtx instead of
+       CONST0_RTX.
+       (gen_rtx_CONST_VECTOR): Rewrite to handle checks for both CONST0_RTX
+       and CONST1_RTX.
+       (init_emit_once): Fix users of gen_const_vector.  Set CONST1_RTX for
+       vector types.
+       * expr.c (const_vector_from_tree): Call gen_rtx_CONST_VECTOR instead
+       of gen_rtx_raw_CONST_VECTOR.
+
 2004-09-10  Eric Christopher  <echristo@redhat.com>
 
        PR c/16046
index ab721fe..1dcda2c 100644 (file)
@@ -194,7 +194,7 @@ static hashval_t reg_attrs_htab_hash (const void *);
 static int reg_attrs_htab_eq (const void *, const void *);
 static reg_attrs *get_reg_attrs (tree, int);
 static tree component_ref_for_mem_expr (tree);
-static rtx gen_const_vector_0 (enum machine_mode);
+static rtx gen_const_vector (enum machine_mode, int);
 static rtx gen_complex_constant_part (enum machine_mode, rtx, int);
 static void copy_rtx_if_shared_1 (rtx *orig);
 
@@ -5162,10 +5162,10 @@ init_emit (void)
 #endif
 }
 
-/* Generate the constant 0.  */
+/* Generate a vector constant for mode MODE and constant value CONSTANT.  */
 
 static rtx
-gen_const_vector_0 (enum machine_mode mode)
+gen_const_vector (enum machine_mode mode, int constant)
 {
   rtx tem;
   rtvec v;
@@ -5177,28 +5177,44 @@ gen_const_vector_0 (enum machine_mode mode)
 
   v = rtvec_alloc (units);
 
-  /* We need to call this function after we to set CONST0_RTX first.  */
-  gcc_assert (CONST0_RTX (inner));
+  /* We need to call this function after we set the scalar const_tiny_rtx
+     entries.  */
+  gcc_assert (const_tiny_rtx[constant][(int) inner]);
 
   for (i = 0; i < units; ++i)
-    RTVEC_ELT (v, i) = CONST0_RTX (inner);
+    RTVEC_ELT (v, i) = const_tiny_rtx[constant][(int) inner];
 
   tem = gen_rtx_raw_CONST_VECTOR (mode, v);
   return tem;
 }
 
 /* Generate a vector like gen_rtx_raw_CONST_VEC, but use the zero vector when
-   all elements are zero.  */
+   all elements are zero, and the one vector when all elements are one.  */
 rtx
 gen_rtx_CONST_VECTOR (enum machine_mode mode, rtvec v)
 {
-  rtx inner_zero = CONST0_RTX (GET_MODE_INNER (mode));
+  enum machine_mode inner = GET_MODE_INNER (mode);
+  int nunits = GET_MODE_NUNITS (mode);
+  rtx x;
   int i;
 
-  for (i = GET_MODE_NUNITS (mode) - 1; i >= 0; i--)
-    if (RTVEC_ELT (v, i) != inner_zero)
-      return gen_rtx_raw_CONST_VECTOR (mode, v);
-  return CONST0_RTX (mode);
+  /* Check to see if all of the elements have the same value.  */
+  x = RTVEC_ELT (v, nunits - 1);
+  for (i = nunits - 2; i >= 0; i--)
+    if (RTVEC_ELT (v, i) != x)
+      break;
+
+  /* If the values are all the same, check to see if we can use one of the
+     standard constant vectors.  */
+  if (i == -1)
+    {
+      if (x == CONST0_RTX (inner))
+       return CONST0_RTX (mode);
+      else if (x == CONST1_RTX (inner))
+       return CONST1_RTX (mode);
+    }
+
+  return gen_rtx_raw_CONST_VECTOR (mode, v);
 }
 
 /* Create some permanent unique rtl objects shared between all functions.
@@ -5352,12 +5368,18 @@ init_emit_once (int line_numbers)
   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_INT);
        mode != VOIDmode;
        mode = GET_MODE_WIDER_MODE (mode))
-    const_tiny_rtx[0][(int) mode] = gen_const_vector_0 (mode);
+    {
+      const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
+      const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
+    }
 
   for (mode = GET_CLASS_NARROWEST_MODE (MODE_VECTOR_FLOAT);
        mode != VOIDmode;
        mode = GET_MODE_WIDER_MODE (mode))
-    const_tiny_rtx[0][(int) mode] = gen_const_vector_0 (mode);
+    {
+      const_tiny_rtx[0][(int) mode] = gen_const_vector (mode, 0);
+      const_tiny_rtx[1][(int) mode] = gen_const_vector (mode, 1);
+    }
 
   for (i = (int) CCmode; i < (int) MAX_MACHINE_MODE; ++i)
     if (GET_MODE_CLASS ((enum machine_mode) i) == MODE_CC)
index 40beef3..44f485b 100644 (file)
@@ -8822,6 +8822,6 @@ const_vector_from_tree (tree exp)
   for (; i < units; ++i)
     RTVEC_ELT (v, i) = CONST0_RTX (inner);
 
-  return gen_rtx_raw_CONST_VECTOR (mode, v);
+  return gen_rtx_CONST_VECTOR (mode, v);
 }
 #include "gt-expr.h"