aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2018-01-02 18:27:50 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-01-02 18:27:50 +0000
commit3877c560656f4961cc50952c3bba3c40812c36c3 (patch)
tree6a597b75586e86b045125cf698b9b23ec15e2d4a /gcc/config
parent8eff75e0d2a3495c5bc182324644a080d47205ac (diff)
downloadgcc-3877c560656f4961cc50952c3bba3c40812c36c3.zip
gcc-3877c560656f4961cc50952c3bba3c40812c36c3.tar.gz
gcc-3877c560656f4961cc50952c3bba3c40812c36c3.tar.bz2
New CONST_VECTOR layout
This patch makes CONST_VECTOR use the same encoding as VECTOR_CST. One problem that occurs in RTL but not at the tree level is that a fair amount of code uses XVEC and XVECEXP directly on CONST_VECTORs (which is valid, just with looser checking). This is complicated by the fact that vectors are also represented as PARALLELs in some target interfaces, so using XVECEXP is a good polymorphic way of handling both forms. Rather than try to untangle all that, the best approach seemed to be to continue to encode every element in a fixed-length vector. That way only target-independent and AArch64 code need to be precise about using CONST_VECTOR_ELT over XVECEXP. After this change is no longer valid to modify CONST_VECTORs in-place. This needed some fix-up in the powerpc backends. 2018-01-02 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * doc/rtl.texi (const_vector): Describe new encoding scheme. * Makefile.in (OBJS): Add rtx-vector-builder.o. * rtx-vector-builder.h: New file. * rtx-vector-builder.c: Likewise. * rtl.h (rtx_def::u2): Add a const_vector field. (CONST_VECTOR_NPATTERNS): New macro. (CONST_VECTOR_NELTS_PER_PATTERN): Likewise. (CONST_VECTOR_DUPLICATE_P): Likewise. (CONST_VECTOR_STEPPED_P): Likewise. (CONST_VECTOR_ENCODED_ELT): Likewise. (const_vec_duplicate_p): Check for a duplicated vector encoding. (unwrap_const_vec_duplicate): Likewise. (const_vec_series_p): Check for a non-duplicated vector encoding. Say that the function only returns true for integer vectors. * emit-rtl.c: Include rtx-vector-builder.h. (gen_const_vec_duplicate_1): Delete. (gen_const_vector): Call gen_const_vec_duplicate instead of gen_const_vec_duplicate_1. (const_vec_series_p_1): Operate directly on the CONST_VECTOR encoding. (gen_const_vec_duplicate): Use rtx_vector_builder. (gen_const_vec_series): Likewise. (gen_rtx_CONST_VECTOR): Likewise. * config/powerpcspe/powerpcspe.c: Include rtx-vector-builder.h. (swap_const_vector_halves): Take an rtx pointer rather than rtx. Build a new vector rather than modifying a CONST_VECTOR in-place. (handle_special_swappables): Update call accordingly. * config/rs6000/rs6000-p8swap.c: Include rtx-vector-builder.h. (swap_const_vector_halves): Take an rtx pointer rather than rtx. Build a new vector rather than modifying a CONST_VECTOR in-place. (handle_special_swappables): Update call accordingly. From-SVN: r256102
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c27
-rw-r--r--gcc/config/rs6000/rs6000-p8swap.c27
2 files changed, 28 insertions, 26 deletions
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 520f2e1..f5868dd 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -79,6 +79,7 @@
#endif
#include "case-cfn-macros.h"
#include "ppc-auxv.h"
+#include "rtx-vector-builder.h"
/* This file should be included last. */
#include "target-def.h"
@@ -42581,23 +42582,24 @@ mark_swaps_for_removal (swap_web_entry *insn_entry, unsigned int i)
}
}
-/* OP is either a CONST_VECTOR or an expression containing one.
+/* *OP_PTR is either a CONST_VECTOR or an expression containing one.
Swap the first half of the vector with the second in the first
case. Recurse to find it in the second. */
static void
-swap_const_vector_halves (rtx op)
+swap_const_vector_halves (rtx *op_ptr)
{
int i;
+ rtx op = *op_ptr;
enum rtx_code code = GET_CODE (op);
if (GET_CODE (op) == CONST_VECTOR)
{
- int half_units = GET_MODE_NUNITS (GET_MODE (op)) / 2;
- for (i = 0; i < half_units; ++i)
- {
- rtx temp = CONST_VECTOR_ELT (op, i);
- CONST_VECTOR_ELT (op, i) = CONST_VECTOR_ELT (op, i + half_units);
- CONST_VECTOR_ELT (op, i + half_units) = temp;
- }
+ int units = GET_MODE_NUNITS (GET_MODE (op));
+ rtx_vector_builder builder (GET_MODE (op), units, 1);
+ for (i = 0; i < units / 2; ++i)
+ builder.quick_push (CONST_VECTOR_ELT (op, i + units / 2));
+ for (i = 0; i < units / 2; ++i)
+ builder.quick_push (CONST_VECTOR_ELT (op, i));
+ *op_ptr = builder.build ();
}
else
{
@@ -42605,10 +42607,10 @@ swap_const_vector_halves (rtx op)
const char *fmt = GET_RTX_FORMAT (code);
for (i = 0; i < GET_RTX_LENGTH (code); ++i)
if (fmt[i] == 'e' || fmt[i] == 'u')
- swap_const_vector_halves (XEXP (op, i));
+ swap_const_vector_halves (&XEXP (op, i));
else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (op, i); ++j)
- swap_const_vector_halves (XVECEXP (op, i, j));
+ swap_const_vector_halves (&XVECEXP (op, i, j));
}
}
@@ -42900,8 +42902,7 @@ handle_special_swappables (swap_web_entry *insn_entry, unsigned i)
{
/* A CONST_VECTOR will only show up somewhere in the RHS of a SET. */
gcc_assert (GET_CODE (body) == SET);
- rtx rhs = SET_SRC (body);
- swap_const_vector_halves (rhs);
+ swap_const_vector_halves (&SET_SRC (body));
if (dump_file)
fprintf (dump_file, "Swapping constant halves in insn %d\n", i);
break;
diff --git a/gcc/config/rs6000/rs6000-p8swap.c b/gcc/config/rs6000/rs6000-p8swap.c
index 7d9ab87..e0d8f31 100644
--- a/gcc/config/rs6000/rs6000-p8swap.c
+++ b/gcc/config/rs6000/rs6000-p8swap.c
@@ -36,6 +36,7 @@
#include "expr.h"
#include "output.h"
#include "tree-pass.h"
+#include "rtx-vector-builder.h"
/* Analyze vector computations and remove unnecessary doubleword
swaps (xxswapdi instructions). This pass is performed only
@@ -931,23 +932,24 @@ mark_swaps_for_removal (swap_web_entry *insn_entry, unsigned int i)
}
}
-/* OP is either a CONST_VECTOR or an expression containing one.
+/* *OP_PTR is either a CONST_VECTOR or an expression containing one.
Swap the first half of the vector with the second in the first
case. Recurse to find it in the second. */
static void
-swap_const_vector_halves (rtx op)
+swap_const_vector_halves (rtx *op_ptr)
{
int i;
+ rtx op = *op_ptr;
enum rtx_code code = GET_CODE (op);
if (GET_CODE (op) == CONST_VECTOR)
{
- int half_units = GET_MODE_NUNITS (GET_MODE (op)) / 2;
- for (i = 0; i < half_units; ++i)
- {
- rtx temp = CONST_VECTOR_ELT (op, i);
- CONST_VECTOR_ELT (op, i) = CONST_VECTOR_ELT (op, i + half_units);
- CONST_VECTOR_ELT (op, i + half_units) = temp;
- }
+ int units = GET_MODE_NUNITS (GET_MODE (op));
+ rtx_vector_builder builder (GET_MODE (op), units, 1);
+ for (i = 0; i < units / 2; ++i)
+ builder.quick_push (CONST_VECTOR_ELT (op, i + units / 2));
+ for (i = 0; i < units / 2; ++i)
+ builder.quick_push (CONST_VECTOR_ELT (op, i));
+ *op_ptr = builder.build ();
}
else
{
@@ -955,10 +957,10 @@ swap_const_vector_halves (rtx op)
const char *fmt = GET_RTX_FORMAT (code);
for (i = 0; i < GET_RTX_LENGTH (code); ++i)
if (fmt[i] == 'e' || fmt[i] == 'u')
- swap_const_vector_halves (XEXP (op, i));
+ swap_const_vector_halves (&XEXP (op, i));
else if (fmt[i] == 'E')
for (j = 0; j < XVECLEN (op, i); ++j)
- swap_const_vector_halves (XVECEXP (op, i, j));
+ swap_const_vector_halves (&XVECEXP (op, i, j));
}
}
@@ -1251,8 +1253,7 @@ handle_special_swappables (swap_web_entry *insn_entry, unsigned i)
{
/* A CONST_VECTOR will only show up somewhere in the RHS of a SET. */
gcc_assert (GET_CODE (body) == SET);
- rtx rhs = SET_SRC (body);
- swap_const_vector_halves (rhs);
+ swap_const_vector_halves (&SET_SRC (body));
if (dump_file)
fprintf (dump_file, "Swapping constant halves in insn %d\n", i);
break;