summaryrefslogtreecommitdiff
path: root/gcc/tree-sra.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-14 15:33:56 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-02-14 15:33:56 +0000
commita32556d5652bebc30c7239d23cffac450f4fbcf3 (patch)
treec501248fa589afafc35f7a550a5f38592d411785 /gcc/tree-sra.c
parentff3209006e18cea3929ab22a052ff5b524f8eb62 (diff)
downloadgcc-a32556d5652bebc30c7239d23cffac450f4fbcf3.tar.gz
2012-02-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52244 PR tree-optimization/51528 * tree-sra.c (analyze_access_subtree): Only create INTEGER_TYPE replacements for integral types. * gcc.dg/torture/pr52244.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184214 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r--gcc/tree-sra.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index e2091e5fda4..1439c43c889 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2172,11 +2172,21 @@ analyze_access_subtree (struct access *root, struct access *parent,
&& (root->grp_scalar_write || root->grp_assignment_write))))
{
bool new_integer_type;
- if (TREE_CODE (root->type) == ENUMERAL_TYPE)
+ /* Always create access replacements that cover the whole access.
+ For integral types this means the precision has to match.
+ Avoid assumptions based on the integral type kind, too. */
+ if (INTEGRAL_TYPE_P (root->type)
+ && (TREE_CODE (root->type) != INTEGER_TYPE
+ || TYPE_PRECISION (root->type) != root->size)
+ /* But leave bitfield accesses alone. */
+ && (root->offset % BITS_PER_UNIT) == 0)
{
tree rt = root->type;
- root->type = build_nonstandard_integer_type (TYPE_PRECISION (rt),
+ root->type = build_nonstandard_integer_type (root->size,
TYPE_UNSIGNED (rt));
+ root->expr = build_ref_for_offset (UNKNOWN_LOCATION,
+ root->base, root->offset,
+ root->type, NULL, false);
new_integer_type = true;
}
else