aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-05-12 09:01:12 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2020-05-12 09:01:12 +0100
commit14605b6bd8c37fffd8065c5c3fe6b1b9d7b2a294 (patch)
treefef1c5025d2ab05315c5357596506ec5e8e55165 /gcc
parentd17a896da1e898928d337596d029f0ece0039d55 (diff)
downloadgcc-14605b6bd8c37fffd8065c5c3fe6b1b9d7b2a294.zip
gcc-14605b6bd8c37fffd8065c5c3fe6b1b9d7b2a294.tar.gz
gcc-14605b6bd8c37fffd8065c5c3fe6b1b9d7b2a294.tar.bz2
tree-vect-generic: Tweak build_replicated_const [PR94980 2/3]
This patch makes build_replicated_const take the number of bits in VALUE rather than calculating the width from the element type. The callers can then use vector_element_bits to calculate the correct element size from the vector type. 2020-05-12 Richard Sandiford <richard.sandiford@arm.com> gcc/ PR tree-optimization/94980 * tree-vect-generic.c (build_replicated_const): Take the number of bits as a parameter, instead of the type of the elements. (do_plus_minus): Update accordingly, using vector_element_bits to calculate the correct number of bits. (do_negate): Likewise.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-vect-generic.c15
2 files changed, 17 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 203cb61..bcaad02 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,15 @@
2020-05-12 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/94980
+ * tree-vect-generic.c (build_replicated_const): Take the number
+ of bits as a parameter, instead of the type of the elements.
+ (do_plus_minus): Update accordingly, using vector_element_bits
+ to calculate the correct number of bits.
+ (do_negate): Likewise.
+
+2020-05-12 Richard Sandiford <richard.sandiford@arm.com>
+
+ PR tree-optimization/94980
* tree.h (vector_element_bits, vector_element_bits_tree): Declare.
* tree.c (vector_element_bits, vector_element_bits_tree): New.
* match.pd: Use the new functions instead of determining the
diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
index 126e906..adea933 100644
--- a/gcc/tree-vect-generic.c
+++ b/gcc/tree-vect-generic.c
@@ -67,11 +67,10 @@ subparts_gt (tree type1, tree type2)
}
/* Build a constant of type TYPE, made of VALUE's bits replicated
- every TYPE_SIZE (INNER_TYPE) bits to fit TYPE's precision. */
+ every WIDTH bits to fit TYPE's precision. */
static tree
-build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value)
+build_replicated_const (tree type, unsigned int width, HOST_WIDE_INT value)
{
- int width = tree_to_uhwi (TYPE_SIZE (inner_type));
int n = (TYPE_PRECISION (type) + HOST_BITS_PER_WIDE_INT - 1)
/ HOST_BITS_PER_WIDE_INT;
unsigned HOST_WIDE_INT low, mask;
@@ -214,13 +213,14 @@ do_plus_minus (gimple_stmt_iterator *gsi, tree word_type, tree a, tree b,
tree bitpos ATTRIBUTE_UNUSED, tree bitsize ATTRIBUTE_UNUSED,
enum tree_code code, tree type ATTRIBUTE_UNUSED)
{
+ unsigned int width = vector_element_bits (TREE_TYPE (a));
tree inner_type = TREE_TYPE (TREE_TYPE (a));
unsigned HOST_WIDE_INT max;
tree low_bits, high_bits, a_low, b_low, result_low, signs;
max = GET_MODE_MASK (TYPE_MODE (inner_type));
- low_bits = build_replicated_const (word_type, inner_type, max >> 1);
- high_bits = build_replicated_const (word_type, inner_type, max & ~(max >> 1));
+ low_bits = build_replicated_const (word_type, width, max >> 1);
+ high_bits = build_replicated_const (word_type, width, max & ~(max >> 1));
a = tree_vec_extract (gsi, word_type, a, bitsize, bitpos);
b = tree_vec_extract (gsi, word_type, b, bitsize, bitpos);
@@ -247,13 +247,14 @@ do_negate (gimple_stmt_iterator *gsi, tree word_type, tree b,
enum tree_code code ATTRIBUTE_UNUSED,
tree type ATTRIBUTE_UNUSED)
{
+ unsigned int width = vector_element_bits (TREE_TYPE (b));
tree inner_type = TREE_TYPE (TREE_TYPE (b));
HOST_WIDE_INT max;
tree low_bits, high_bits, b_low, result_low, signs;
max = GET_MODE_MASK (TYPE_MODE (inner_type));
- low_bits = build_replicated_const (word_type, inner_type, max >> 1);
- high_bits = build_replicated_const (word_type, inner_type, max & ~(max >> 1));
+ low_bits = build_replicated_const (word_type, width, max >> 1);
+ high_bits = build_replicated_const (word_type, width, max & ~(max >> 1));
b = tree_vec_extract (gsi, word_type, b, bitsize, bitpos);