Commit 1abc0f7f by Richard Biener Committed by Richard Biener

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
parent d71488c0
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> 2018-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc/config/msp430/msp430.c (msp430_attr): Allow interrupt handlers * gcc/config/msp430/msp430.c (msp430_attr): Allow interrupt handlers
......
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> 2018-06-05 Steve Ellcey <sellcey@cavium.com>
PR target/79924 PR target/79924
......
// { 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" } }
...@@ -2270,14 +2270,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -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. */ /* Apply an extra offset to the inner MEM_REF of the RHS. */
if (maybe_ne (extra_off, 0)) if (maybe_ne (extra_off, 0))
{ {
if (rhs.length () < 2 if (rhs.length () < 2)
|| rhs[0].opcode != MEM_REF
|| known_eq (rhs[0].off, -1))
return (void *)-1; return (void *)-1;
rhs[0].off += extra_off; int ix = rhs.length () - 2;
rhs[0].op0 = int_const_binop (PLUS_EXPR, rhs[0].op0, if (rhs[ix].opcode != MEM_REF
build_int_cst (TREE_TYPE (rhs[0].op0), || known_eq (rhs[ix].off, -1))
extra_off)); 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. */ /* We need to pre-pend vr->operands[0..i] to rhs. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment