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
This commit is contained in:
Richard Biener 2018-06-06 13:03:29 +00:00 committed by Richard Biener
parent d71488c017
commit 1abc0f7f52
4 changed files with 44 additions and 7 deletions

View file

@ -1,3 +1,10 @@
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.
2018-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc/config/msp430/msp430.c (msp430_attr): Allow interrupt handlers

View file

@ -1,3 +1,8 @@
2018-06-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/86062
* g++.dg/tree-ssa/pr86062.C: New testcase.
2018-06-05 Steve Ellcey <sellcey@cavium.com>
PR target/79924

View file

@ -0,0 +1,23 @@
// { dg-do compile }
// { dg-require-effective-target c++14 }
// { dg-options "-O2 -ffinite-math-only -fdump-tree-fre1" }
#include <array>
struct I { double i,s; I(double d):i(d),s(d){} };
typedef std::array<double,3> P;
typedef std::array<I,3> AP;
static AP c(P const&p){
return {p[0],p[1],p[2]};
}
template<class T> auto const& ac(T const&p, int n){return p[n];}
static double g(P const&p, int n)
{
I res = ac(c(p),n);
return res.s-res.i;
}
__attribute__((flatten)) double fff(P p){ return g(p,1); }
// { dg-final { scan-tree-dump "return 0.0;" "fre1" } }

View file

@ -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. */