diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-12-03 18:06:40 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-12-03 18:06:40 +0000 |
commit | bd8a2482569900a114d631f9c38353d3a96a1d85 (patch) | |
tree | 0f1dac36e3df9cab6b3e4a4ff088a07ec4b2e2fa /gcc/cgraphunit.c | |
parent | 2c98350fcb269a653b11f73ca0175679aa29977a (diff) | |
download | gcc-bd8a2482569900a114d631f9c38353d3a96a1d85.zip gcc-bd8a2482569900a114d631f9c38353d3a96a1d85.tar.gz gcc-bd8a2482569900a114d631f9c38353d3a96a1d85.tar.bz2 |
Don't install unnecessary ARRAY_REF element sizes
Even EXACT_DIV_EXPR doesn't distribute across addition for wrapping
types, so in general we can't fold EXACT_DIV_EXPRs of POLY_INT_CSTs
at compile time. This was causing an ICE when trying to gimplify the
element size field in an ARRAY_REF.
If the result of that EXACT_DIV_EXPR is an invariant, we don't bother
recording it in the ARRAY_REF and simply read the element size from the
element type. This avoids the overhead of doing:
/* ??? tree_ssa_useless_type_conversion will eliminate casts to
sizetype from another type of the same width and signedness. */
if (TREE_TYPE (aligned_size) != sizetype)
aligned_size = fold_convert_loc (loc, sizetype, aligned_size);
return size_binop_loc (loc, MULT_EXPR, aligned_size,
size_int (TYPE_ALIGN_UNIT (elmt_type)));
each time array_ref_element_size is called.
So rather than read array_ref_element_size, do some arithmetic on it,
and only then check whether the result is an invariant, we might as
well check whether the element size is an invariant to start with.
We're then directly testing whether array_ref_element_size gives
a reusable value.
For consistency, the patch makes the same change for the offset field
in a COMPONENT_REF, although I don't think that can trigger yet.
2019-12-03 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* gimplify.c (gimplify_compound_lval): Don't gimplify and install
an array element size if array_element_size is already an invariant.
Similarly don't gimplify and install a field offset if
component_ref_field_offset is already an invariant.
gcc/testsuite/
* gcc.target/aarch64/sve/acle/general-c/struct_1.c: New test.
From-SVN: r278942
Diffstat (limited to 'gcc/cgraphunit.c')
0 files changed, 0 insertions, 0 deletions