diff mbox series

Mostly revert r254296

Message ID 87r2r2ezia.fsf@linaro.org
State New
Headers show
Series Mostly revert r254296 | expand

Commit Message

Richard Sandiford Jan. 7, 2018, 10:26 a.m. UTC
r254296 added support for (const ...) wrappers around vectors,
but in the end the agreement was to use a variable-length
encoding of CONST_VECTOR (and VECTOR_CST) instead.  This patch
therefore reverts the bits that are no longer needed.

The rtl.texi part isn't a full revert, since r254296 also updated the
documentation to mention unspecs in address calculations, and to relax
the requirement that the mode had to be Pmode (it can also be ptr_mode
on target where Pmode != ptr_mode).

Tested on aarch64-linux-gnu.  OK to install?  (Although AIUI reverts
don't normally need approval, I thought I'd better ask given the
rtl.texi thing.)

Richard


2018-01-06  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* doc/rtl.texi: Remove documentation of (const ...) wrappers
	for vectors, as a partial revert of r254296.
	* rtl.h (const_vec_p): Delete.
	(const_vec_duplicate_p): Don't test for vector CONSTs.
	(unwrap_const_vec_duplicate, const_vec_series_p): Likewise.
	* expmed.c (make_tree): Likewise.

	Revert:
	* common.md (E, F): Use CONSTANT_P instead of checking for
	CONST_VECTOR.
	* emit-rtl.c (gen_lowpart_common): Use const_vec_p instead of
	checking for CONST_VECTOR.

Comments

Jeff Law Jan. 9, 2018, 11:45 p.m. UTC | #1
On 01/07/2018 03:26 AM, Richard Sandiford wrote:
> r254296 added support for (const ...) wrappers around vectors,
> but in the end the agreement was to use a variable-length
> encoding of CONST_VECTOR (and VECTOR_CST) instead.  This patch
> therefore reverts the bits that are no longer needed.
> 
> The rtl.texi part isn't a full revert, since r254296 also updated the
> documentation to mention unspecs in address calculations, and to relax
> the requirement that the mode had to be Pmode (it can also be ptr_mode
> on target where Pmode != ptr_mode).
> 
> Tested on aarch64-linux-gnu.  OK to install?  (Although AIUI reverts
> don't normally need approval, I thought I'd better ask given the
> rtl.texi thing.)
> 
> Richard
> 
> 
> 2018-01-06  Richard Sandiford  <richard.sandiford@linaro.org>
> 
> gcc/
> 	* doc/rtl.texi: Remove documentation of (const ...) wrappers
> 	for vectors, as a partial revert of r254296.
> 	* rtl.h (const_vec_p): Delete.
> 	(const_vec_duplicate_p): Don't test for vector CONSTs.
> 	(unwrap_const_vec_duplicate, const_vec_series_p): Likewise.
> 	* expmed.c (make_tree): Likewise.
> 
> 	Revert:
> 	* common.md (E, F): Use CONSTANT_P instead of checking for
> 	CONST_VECTOR.
> 	* emit-rtl.c (gen_lowpart_common): Use const_vec_p instead of
> 	checking for CONST_VECTOR.
Never hurts to verify.  OK.
jeff
diff mbox series

Patch

Index: gcc/doc/rtl.texi
===================================================================
--- gcc/doc/rtl.texi	2018-01-04 18:05:23.717283885 +0000
+++ gcc/doc/rtl.texi	2018-01-07 10:21:06.115727720 +0000
@@ -1875,18 +1875,12 @@  Usually that is the only mode for which
 
 @findex const
 @item (const:@var{m} @var{exp})
-Wraps an rtx computation @var{exp} whose inputs and result do not
-change during the execution of a thread.  There are two valid uses.
-The first is to represent a global or thread-local address calculation.
-In this case @var{exp} should contain @code{const_int},
-@code{symbol_ref}, @code{label_ref} or @code{unspec} expressions,
-combined with @code{plus} and @code{minus}.  Any such @code{unspec}s
-are target-specific and typically represent some form of relocation
-operator.  @var{m} should be a valid address mode.
-
-The second use of @code{const} is to wrap a vector operation.
-In this case @var{exp} must be a @code{vec_duplicate} or
-@code{vec_series} expression.
+Represents a constant that is the result of an assembly-time
+arithmetic computation.  The operand, @var{exp}, contains only
+@code{const_int}, @code{symbol_ref}, @code{label_ref} or @code{unspec}
+expressions, combined with @code{plus} and @code{minus}.  Any such
+@code{unspec}s are target-specific and typically represent some form
+of relocation operator.  @var{m} should be a valid address mode.
 
 @findex high
 @item (high:@var{m} @var{exp})
Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h	2018-01-06 11:06:04.969430563 +0000
+++ gcc/rtl.h	2018-01-07 10:21:06.117728188 +0000
@@ -2935,24 +2935,14 @@  extern rtx shallow_copy_rtx (const_rtx C
 extern int rtx_equal_p (const_rtx, const_rtx);
 extern bool rtvec_all_equal_p (const_rtvec);
 
-/* Return true if X is some form of vector constant.  */
-
-inline bool
-const_vec_p (const_rtx x)
-{
-  return VECTOR_MODE_P (GET_MODE (x)) && CONSTANT_P (x);
-}
-
 /* Return true if X is a vector constant with a duplicated element value.  */
 
 inline bool
 const_vec_duplicate_p (const_rtx x)
 {
-  return ((GET_CODE (x) == CONST_VECTOR
-	   && CONST_VECTOR_NPATTERNS (x) == 1
-	   && CONST_VECTOR_DUPLICATE_P (x))
-	  || (GET_CODE (x) == CONST
-	      && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE));
+  return (GET_CODE (x) == CONST_VECTOR
+	  && CONST_VECTOR_NPATTERNS (x) == 1
+	  && CONST_VECTOR_DUPLICATE_P (x));
 }
 
 /* Return true if X is a vector constant with a duplicated element value.
@@ -2962,20 +2952,11 @@  const_vec_duplicate_p (const_rtx x)
 inline bool
 const_vec_duplicate_p (T x, T *elt)
 {
-  if (GET_CODE (x) == CONST_VECTOR
-      && CONST_VECTOR_NPATTERNS (x) == 1
-      && CONST_VECTOR_DUPLICATE_P (x))
+  if (const_vec_duplicate_p (x))
     {
       *elt = CONST_VECTOR_ENCODED_ELT (x, 0);
       return true;
     }
-  if (GET_CODE (x) == CONST
-      && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE
-      && !VECTOR_MODE_P (GET_MODE (XEXP (XEXP (x, 0), 0))))
-    {
-      *elt = XEXP (XEXP (x, 0), 0);
-      return true;
-    }
   return false;
 }
 
@@ -3002,12 +2983,8 @@  vec_duplicate_p (T x, T *elt)
 inline T
 unwrap_const_vec_duplicate (T x)
 {
-  if (GET_CODE (x) == CONST_VECTOR
-      && CONST_VECTOR_NPATTERNS (x) == 1
-      && CONST_VECTOR_DUPLICATE_P (x))
-    return CONST_VECTOR_ENCODED_ELT (x, 0);
-  if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_DUPLICATE)
-    return XEXP (XEXP (x, 0), 0);
+  if (const_vec_duplicate_p (x))
+    x = CONST_VECTOR_ELT (x, 0);
   return x;
 }
 
@@ -3030,12 +3007,6 @@  const_vec_series_p (const_rtx x, rtx *ba
       && CONST_VECTOR_NPATTERNS (x) == 1
       && !CONST_VECTOR_DUPLICATE_P (x))
     return const_vec_series_p_1 (x, base_out, step_out);
-  if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == VEC_SERIES)
-    {
-      *base_out = XEXP (XEXP (x, 0), 0);
-      *step_out = XEXP (XEXP (x, 0), 1);
-      return true;
-    }
   return false;
 }
 
Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c	2018-01-07 10:16:53.825977531 +0000
+++ gcc/expmed.c	2018-01-07 10:21:06.116727954 +0000
@@ -5355,22 +5355,7 @@  make_tree (tree type, rtx x)
       return fold_convert (type, make_tree (t, XEXP (x, 0)));
 
     case CONST:
-      {
-	rtx op = XEXP (x, 0);
-	if (GET_CODE (op) == VEC_DUPLICATE)
-	  {
-	    tree elt_tree = make_tree (TREE_TYPE (type), XEXP (op, 0));
-	    return build_vector_from_val (type, elt_tree);
-	  }
-	if (GET_CODE (op) == VEC_SERIES)
-	  {
-	    tree itype = TREE_TYPE (type);
-	    tree base_tree = make_tree (itype, XEXP (op, 0));
-	    tree step_tree = make_tree (itype, XEXP (op, 1));
-	    return build_vec_series (type, base_tree, step_tree);
-	  }
-	return make_tree (type, op);
-      }
+      return make_tree (type, XEXP (x, 0));
 
     case SYMBOL_REF:
       t = SYMBOL_REF_DECL (x);
Index: gcc/common.md
===================================================================
--- gcc/common.md	2018-01-03 11:12:59.086630758 +0000
+++ gcc/common.md	2018-01-07 10:21:06.115727720 +0000
@@ -80,14 +80,14 @@  (define_constraint "n"
 (define_constraint "E"
   "Matches a floating-point constant."
   (ior (match_test "CONST_DOUBLE_AS_FLOAT_P (op)")
-       (match_test "CONSTANT_P (op)
+       (match_test "GET_CODE (op) == CONST_VECTOR
 		    && GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT")))
 
 ;; There is no longer a distinction between "E" and "F".
 (define_constraint "F"
   "Matches a floating-point constant."
   (ior (match_test "CONST_DOUBLE_AS_FLOAT_P (op)")
-       (match_test "CONSTANT_P (op)
+       (match_test "GET_CODE (op) == CONST_VECTOR
 		    && GET_MODE_CLASS (GET_MODE (op)) == MODE_VECTOR_FLOAT")))
 
 (define_constraint "X"
Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	2018-01-03 21:42:54.277273515 +0000
+++ gcc/emit-rtl.c	2018-01-07 10:21:06.116727954 +0000
@@ -1593,7 +1593,7 @@  gen_lowpart_common (machine_mode mode, r
 	return gen_rtx_fmt_e (GET_CODE (x), int_mode, XEXP (x, 0));
     }
   else if (GET_CODE (x) == SUBREG || REG_P (x)
-	   || GET_CODE (x) == CONCAT || const_vec_p (x)
+	   || GET_CODE (x) == CONCAT || GET_CODE (x) == CONST_VECTOR
 	   || CONST_DOUBLE_AS_FLOAT_P (x) || CONST_SCALAR_INT_P (x)
 	   || CONST_POLY_INT_P (x))
     return lowpart_subreg (mode, x, innermode);