diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-12-07 18:42:41 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-12-07 18:42:41 +0000 |
commit | 63570af0b58a3c354723bc78b75d76dbb0750f47 (patch) | |
tree | 7b1f2b8c0da2c3908d22d25dcea31ceacd492de2 /gcc/fold-const.c | |
parent | 44e1aae4dbd8198a26ab0ec5958e073e2c9cc772 (diff) | |
download | gcc-63570af0b58a3c354723bc78b75d76dbb0750f47.zip gcc-63570af0b58a3c354723bc78b75d76dbb0750f47.tar.gz gcc-63570af0b58a3c354723bc78b75d76dbb0750f47.tar.bz2 |
Make more use of VECTOR_CST_ENCODED_ELT
This patch makes various bits of code operate directly on the new
VECTOR_CST encoding, instead of using VECTOR_CST_ELT on all elements
of the vector.
Previous patches handled operations that produce a new VECTOR_CST,
while this patch handles things like predicates. It also makes
print_node dump the encoding instead of the full vector that
the encoding represents.
2017-12-07 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* tree-vector-builder.h
(tree_vector_builder::binary_encoded_nelts): Declare.
* tree-vector-builder.c
(tree_vector_builder::binary_encoded_nelts): New function.
* fold-const.c (negate_expr_p): Likewise.
(operand_equal_p, fold_checksum_tree): Likewise.
* tree-loop-distribution.c (const_with_all_bytes_same): Likewise.
* tree.c (integer_zerop, integer_onep, integer_all_onesp, real_zerop)
(real_onep, real_minus_onep, add_expr, initializer_zerop): Likewise.
(uniform_vector_p): Likewise.
* varasm.c (const_hash_1, compare_constant): Likewise.
* tree-ssa-ccp.c: Include tree-vector-builder.h.
(valid_lattice_transition): Operate directly on the VECTOR_CST
encoding.
* ipa-icf.c: Include tree-vector-builder.h.
(sem_variable::equals): Operate directly on the VECTOR_CST encoding.
* print-tree.c (print_node): Print encoding of VECTOR_CSTs.
From-SVN: r255480
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1b098d9..0f11076 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -410,10 +410,10 @@ negate_expr_p (tree t) if (FLOAT_TYPE_P (TREE_TYPE (type)) || TYPE_OVERFLOW_WRAPS (type)) return true; - int count = VECTOR_CST_NELTS (t), i; - - for (i = 0; i < count; i++) - if (!negate_expr_p (VECTOR_CST_ELT (t, i))) + /* Steps don't prevent negation. */ + unsigned int count = vector_cst_encoded_nelts (t); + for (unsigned int i = 0; i < count; ++i) + if (!negate_expr_p (VECTOR_CST_ENCODED_ELT (t, i))) return false; return true; @@ -2981,17 +2981,19 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) case VECTOR_CST: { - unsigned i; + if (VECTOR_CST_LOG2_NPATTERNS (arg0) + != VECTOR_CST_LOG2_NPATTERNS (arg1)) + return 0; - if (VECTOR_CST_NELTS (arg0) != VECTOR_CST_NELTS (arg1)) + if (VECTOR_CST_NELTS_PER_PATTERN (arg0) + != VECTOR_CST_NELTS_PER_PATTERN (arg1)) return 0; - for (i = 0; i < VECTOR_CST_NELTS (arg0); ++i) - { - if (!operand_equal_p (VECTOR_CST_ELT (arg0, i), - VECTOR_CST_ELT (arg1, i), flags)) - return 0; - } + unsigned int count = vector_cst_encoded_nelts (arg0); + for (unsigned int i = 0; i < count; ++i) + if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (arg0, i), + VECTOR_CST_ENCODED_ELT (arg1, i), flags)) + return 0; return 1; } @@ -11992,8 +11994,9 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx, fold_checksum_tree (TREE_IMAGPART (expr), ctx, ht); break; case VECTOR_CST: - for (i = 0; i < (int) VECTOR_CST_NELTS (expr); ++i) - fold_checksum_tree (VECTOR_CST_ELT (expr, i), ctx, ht); + len = vector_cst_encoded_nelts (expr); + for (i = 0; i < len; ++i) + fold_checksum_tree (VECTOR_CST_ENCODED_ELT (expr, i), ctx, ht); break; default: break; |