diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2017-12-07 18:40:28 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-12-07 18:40:28 +0000 |
commit | 734914b6e230b78eb6c34fbd5a2d93b1a919d36a (patch) | |
tree | 464ddba276c629fcc0b513ee176e7938bd409fc7 /gcc/lto | |
parent | a0e7e36ebfe748057a6a6e105dbaa315eb0e46ac (diff) | |
download | gcc-734914b6e230b78eb6c34fbd5a2d93b1a919d36a.zip gcc-734914b6e230b78eb6c34fbd5a2d93b1a919d36a.tar.gz gcc-734914b6e230b78eb6c34fbd5a2d93b1a919d36a.tar.bz2 |
New VECTOR_CST layout
This patch uses a simple compression scheme to represent the contents
of a VECTOR_CST using its leading elements. There are three formats:
1) a repeating sequence of N values. This is encoded using the first
N elements.
2) a "foreground" sequence of N values inserted at the beginning of
a "background" repeating sequence of N values, such as:
{ 1, 2, 0, 0, 0, 0, ... }. This is encoded using the first 2*N
elements.
2) a "foreground" sequence of N values inserted at the beginning of
a "background" repeating sequence of N interleaved linear series,
such as: { 0, 0, 8, 10, 9, 11, 10, 12, ... }. This is encoded
using the first 3*N elements. In practice the foreground values
are often part of the same series as the background values,
such as: { 1, 11, 2, 12, 3, 13, ... }.
This reduces the amount of work involved in processing simple
vector constants and means that the encoding extends naturally
to variable-length vectors.
2017-12-07 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* doc/generic.texi (VECTOR_CST): Describe new representation of
vector constants.
* vector-builder.h: New file.
* tree-vector-builder.h: Likewise.
* tree-vector-builder.c: Likewise.
* Makefile.in (OBJS): Add tree-vector-builder.o.
* tree.def (VECTOR_CST): Update comment to refer to generic.texi.
* tree-core.h (tree_base): Add a vector_cst field to the u union.
(tree_vector): Change the number of elements to
vector_cst_encoded_nelts.
* tree.h (VECTOR_CST_NELTS): Redefine using TYPE_VECTOR_SUBPARTS.
(VECTOR_CST_ELTS): Delete.
(VECTOR_CST_ELT): Redefine using vector_cst_elt.
(VECTOR_CST_LOG2_NPATTERNS, VECTOR_CST_NPATTERNS): New macros.
(VECTOR_CST_NELTS_PER_PATTERN, VECTOR_CST_DUPLICATE_P): Likewise.
(VECTOR_CST_STEPPED_P, VECTOR_CST_ENCODED_ELTS): Likewise.
(VECTOR_CST_ENCODED_ELT): Likewise.
(vector_cst_encoded_nelts): New function.
(make_vector): Take the values of VECTOR_CST_LOG2_NPATTERNS and
VECTOR_CST_NELTS_PER_PATTERN as arguments.
(vector_cst_int_elt, vector_cst_elt): Declare.
* tree.c: Include tree-vector-builder.h.
(tree_code_size): Abort if passed VECTOR_CST.
(tree_size): Update for new VECTOR_CST layout.
(make_vector): Take the values of VECTOR_CST_LOG2_NPATTERNS and
VECTOR_CST_NELTS_PER_PATTERN as arguments.
(build_vector): Use tree_vector_builder.
(vector_cst_int_elt, vector_cst_elt): New functions.
(drop_tree_overflow): For VECTOR_CST, drop the TREE_OVERFLOW from the
encoded elements and then create the vector in the canonical form.
(check_vector_cst, check_vector_cst_duplicate, check_vector_cst_fill)
(check_vector_cst_stepped, test_vector_cst_patterns): New functions.
(tree_c_tests): Call test_vector_cst_patterns.
* lto-streamer-out.c (DFS::DFS_write_tree_body): Handle the new
VECTOR_CST fields.
(hash_tree): Likewise.
* tree-streamer-out.c (write_ts_vector_tree_pointers): Likewise.
(streamer_write_tree_header): Likewise.
* tree-streamer-in.c (lto_input_ts_vector_tree_pointers): Likewise.
(streamer_alloc_tree): Likewise. Update call to make_vector.
* fold-const.c (fold_ternary_loc): Avoid using VECTOR_CST_ELTS.
gcc/lto/
* lto.c (compare_tree_sccs_1): Compare the new VECTOR_CST flags.
From-SVN: r255474
Diffstat (limited to 'gcc/lto')
-rw-r--r-- | gcc/lto/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/lto/lto.c | 13 |
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index b8260a0..4823dc2 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,7 @@ +2017-12-07 Richard Sandiford <richard.sandiford@arm.com> + + * lto.c (compare_tree_sccs_1): Compare the new VECTOR_CST flags. + 2017-12-07 Martin Sebor <msebor@redhat.com> PR c/81544 diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index ae9bae8..e330644 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1065,6 +1065,12 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) TREE_FIXED_CST_PTR (t1), TREE_FIXED_CST_PTR (t2))) return false; + if (CODE_CONTAINS_STRUCT (code, TS_VECTOR)) + { + compare_values (VECTOR_CST_LOG2_NPATTERNS); + compare_values (VECTOR_CST_NELTS_PER_PATTERN); + } + if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON)) { compare_values (DECL_MODE); @@ -1281,11 +1287,12 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map) if (CODE_CONTAINS_STRUCT (code, TS_VECTOR)) { - unsigned i; /* Note that the number of elements for EXPR has already been emitted in EXPR's header (see streamer_write_tree_header). */ - for (i = 0; i < VECTOR_CST_NELTS (t1); ++i) - compare_tree_edges (VECTOR_CST_ELT (t1, i), VECTOR_CST_ELT (t2, i)); + unsigned int count = vector_cst_encoded_nelts (t1); + for (unsigned int i = 0; i < count; ++i) + compare_tree_edges (VECTOR_CST_ENCODED_ELT (t1, i), + VECTOR_CST_ENCODED_ELT (t2, i)); } if (CODE_CONTAINS_STRUCT (code, TS_COMPLEX)) |