aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-04-07 09:20:42 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-04-07 09:20:42 +0200
commiteda71a9eeaaf1ea16ba56d8cc5a4eb194f6025f7 (patch)
treeb1acf024b403009d0a3344de142b9f251ad1c416 /gcc/tree-ssa-sccvn.c
parentf1a0afe2aa1447c2d7962f52e8e278c40ba5fe19 (diff)
downloadgcc-eda71a9eeaaf1ea16ba56d8cc5a4eb194f6025f7.zip
gcc-eda71a9eeaaf1ea16ba56d8cc5a4eb194f6025f7.tar.gz
gcc-eda71a9eeaaf1ea16ba56d8cc5a4eb194f6025f7.tar.bz2
re PR tree-optimization/85257 (wrong code with -O -fno-tree-ccp and reading zeroed vector member)
PR tree-optimization/85257 * fold-const.c (native_encode_vector): If not all elts could fit and off is -1, return 0 rather than offset. * tree-ssa-sccvn.c (vn_reference_lookup_3): Pass (offseti - offset2) / BITS_PER_UNIT as 4th argument to native_encode_expr. Verify len * BITS_PER_UNIT >= maxsizei. Don't adjust buffer in native_interpret_expr call. * gcc.dg/pr85257.c: New test. From-SVN: r259206
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 4e5f338..1463c1d 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2038,8 +2038,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
if (TREE_CODE (rhs) == SSA_NAME)
rhs = SSA_VAL (rhs);
len = native_encode_expr (gimple_assign_rhs1 (def_stmt),
- buffer, sizeof (buffer));
- if (len > 0)
+ buffer, sizeof (buffer),
+ (offseti - offset2) / BITS_PER_UNIT);
+ if (len > 0 && len * BITS_PER_UNIT >= maxsizei)
{
tree type = vr->type;
/* Make sure to interpret in a type that has a range
@@ -2048,10 +2049,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
&& maxsizei != TYPE_PRECISION (vr->type))
type = build_nonstandard_integer_type (maxsizei,
TYPE_UNSIGNED (type));
- tree val = native_interpret_expr (type,
- buffer
- + ((offseti - offset2)
- / BITS_PER_UNIT),
+ tree val = native_interpret_expr (type, buffer,
maxsizei / BITS_PER_UNIT);
/* If we chop off bits because the types precision doesn't
match the memory access size this is ok when optimizing