aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-05-11 14:04:32 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-05-11 14:04:32 +0000
commitf35ea97de898081cb04ceaa6bca97d2b719e7c47 (patch)
tree36b22664ec960b7983947166fc32bd195c9c804c /gcc/tree-ssa-sccvn.c
parentdff70323a39a34ba26c729f50fe45d78912133e8 (diff)
downloadgcc-f35ea97de898081cb04ceaa6bca97d2b719e7c47.zip
gcc-f35ea97de898081cb04ceaa6bca97d2b719e7c47.tar.gz
gcc-f35ea97de898081cb04ceaa6bca97d2b719e7c47.tar.bz2
re PR tree-optimization/71055 (FAIL: gcc.dg/torture/pr53663-1.c -Os execution test)
2016-05-11 Richard Biener <rguenther@suse.de> PR tree-optimization/71055 * tree-ssa-sccvn.c (vn_reference_lookup_3): When native-interpreting sth with precision not equal to access size verify we don't chop off bits. * gcc.dg/torture/pr71055.c: New testcase. From-SVN: r236122
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 6344117..1567fb9 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1907,14 +1907,34 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
buffer, sizeof (buffer));
if (len > 0)
{
- tree val = native_interpret_expr (vr->type,
+ tree type = vr->type;
+ /* Make sure to interpret in a type that has a range
+ covering the whole access size. */
+ if (INTEGRAL_TYPE_P (vr->type)
+ && ref->size != TYPE_PRECISION (vr->type))
+ type = build_nonstandard_integer_type (ref->size,
+ TYPE_UNSIGNED (type));
+ tree val = native_interpret_expr (type,
buffer
+ ((offset - offset2)
/ BITS_PER_UNIT),
ref->size / BITS_PER_UNIT);
+ /* If we chop off bits because the types precision doesn't
+ match the memory access size this is ok when optimizing
+ reads but not when called from the DSE code during
+ elimination. */
+ if (val
+ && type != vr->type)
+ {
+ if (! int_fits_type_p (val, vr->type))
+ val = NULL_TREE;
+ else
+ val = fold_convert (vr->type, val);
+ }
+
if (val)
return vn_reference_lookup_or_insert_for_pieces
- (vuse, vr->set, vr->type, vr->operands, val);
+ (vuse, vr->set, vr->type, vr->operands, val);
}
}
}