aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-sccvn.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-06-06 13:03:29 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-06-06 13:03:29 +0000
commit1abc0f7f52c01e5fd1a8149eab1b5f4ad4e92fa5 (patch)
tree58c12e9abe514f02b058641bd4b7b4823d151ded /gcc/tree-ssa-sccvn.c
parentd71488c017b4ebb932cf2b4a43656e1eda670b23 (diff)
downloadgcc-1abc0f7f52c01e5fd1a8149eab1b5f4ad4e92fa5.zip
gcc-1abc0f7f52c01e5fd1a8149eab1b5f4ad4e92fa5.tar.gz
gcc-1abc0f7f52c01e5fd1a8149eab1b5f4ad4e92fa5.tar.bz2
re PR tree-optimization/86062 (Missed redundancy elimination with struct and array)
2018-06-06 Richard Biener <rguenther@suse.de> PR tree-optimization/86062 * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle arbitrary component refs ontop of to be offsetted base. * g++.dg/tree-ssa/pr86062.C: New testcase. From-SVN: r261231
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r--gcc/tree-ssa-sccvn.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 4e946ba..4aec41e 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -2270,14 +2270,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
/* Apply an extra offset to the inner MEM_REF of the RHS. */
if (maybe_ne (extra_off, 0))
{
- if (rhs.length () < 2
- || rhs[0].opcode != MEM_REF
- || known_eq (rhs[0].off, -1))
+ if (rhs.length () < 2)
return (void *)-1;
- rhs[0].off += extra_off;
- rhs[0].op0 = int_const_binop (PLUS_EXPR, rhs[0].op0,
- build_int_cst (TREE_TYPE (rhs[0].op0),
- extra_off));
+ int ix = rhs.length () - 2;
+ if (rhs[ix].opcode != MEM_REF
+ || known_eq (rhs[ix].off, -1))
+ return (void *)-1;
+ rhs[ix].off += extra_off;
+ rhs[ix].op0 = int_const_binop (PLUS_EXPR, rhs[ix].op0,
+ build_int_cst (TREE_TYPE (rhs[ix].op0),
+ extra_off));
}
/* We need to pre-pend vr->operands[0..i] to rhs. */