aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-09-25 11:13:13 +0200
committerRichard Biener <rguenther@suse.de>2020-09-25 14:51:26 +0200
commitd16b5975ca985cbe97698479fc38b6a636886978 (patch)
tree741667dbea2762008ae58b2061e5e2bb38638aaf /gcc/expr.c
parent7bfc4cd2c812a3197c09797796828459714f8849 (diff)
downloadgcc-d16b5975ca985cbe97698479fc38b6a636886978.zip
gcc-d16b5975ca985cbe97698479fc38b6a636886978.tar.gz
gcc-d16b5975ca985cbe97698479fc38b6a636886978.tar.bz2
middle-end/96814 - fix VECTOR_BOOLEAN_TYPE_P CTOR RTL expansion
The RTL expansion code for CTORs doesn't handle VECTOR_BOOLEAN_TYPE_P with bit-precision elements correctly as the testcase shows before the PR97085 fix. The following makes it do the correct thing (not 100% sure for CTOR of sub-vectors due to the lack of a testcase). The alternative would be to assert such CTORs do not happen (and also add IL verification for this). The GIMPLE FE needs a way to declare the VECTOR_BOOLEAN_TYPE_P vectors (thus the C FE needs that). 2020-09-25 Richard Biener <rguenther@suse.de> PR middle-end/96814 * expr.c (store_constructor): Handle VECTOR_BOOLEAN_TYPE_P CTORs correctly. * gcc.target/i386/pr96814.c: New testcase.
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 1a15f24..1c79518 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -6922,7 +6922,7 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
insn_code icode = CODE_FOR_nothing;
tree elt;
tree elttype = TREE_TYPE (type);
- int elt_size = tree_to_uhwi (TYPE_SIZE (elttype));
+ int elt_size = vector_element_bits (type);
machine_mode eltmode = TYPE_MODE (elttype);
HOST_WIDE_INT bitsize;
HOST_WIDE_INT bitpos;
@@ -6987,6 +6987,15 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
}
}
+ /* Compute the size of the elements in the CTOR. It differs
+ from the size of the vector type elements only when the
+ CTOR elements are vectors themselves. */
+ tree val_type = TREE_TYPE (CONSTRUCTOR_ELT (exp, 0)->value);
+ if (VECTOR_TYPE_P (val_type))
+ bitsize = tree_to_uhwi (TYPE_SIZE (val_type));
+ else
+ bitsize = elt_size;
+
/* If the constructor has fewer elements than the vector,
clear the whole array first. Similarly if this is static
constructor of a non-BLKmode object. */
@@ -7001,11 +7010,7 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value)
{
- tree sz = TYPE_SIZE (TREE_TYPE (value));
- int n_elts_here
- = tree_to_uhwi (int_const_binop (TRUNC_DIV_EXPR, sz,
- TYPE_SIZE (elttype)));
-
+ int n_elts_here = bitsize / elt_size;
count += n_elts_here;
if (mostly_zeros_p (value))
zero_count += n_elts_here;
@@ -7045,7 +7050,6 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size,
HOST_WIDE_INT eltpos;
tree value = ce->value;
- bitsize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (value)));
if (cleared && initializer_zerop (value))
continue;