From e65757f3598cd955c6880b2809fe5e8930bca208 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 28 May 2015 13:24:53 +0000 Subject: [PATCH] re PR tree-optimization/66142 (Loop is not vectorized because not sufficient support for GOMP_SIMD_LANE) 2015-05-28 Richard Biener PR tree-optimization/66142 * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle non-GIMPLE values better in memcpy destination handling. Handle non-aliasing we discover here. * gcc.dg/tree-ssa/ssa-fre-44.c: Fixup. From-SVN: r223816 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-44.c | 1 - gcc/tree-ssa-sccvn.c | 20 ++++++++++++++++++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0603918fddc..9e8110443aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-05-28 Richard Biener + + PR tree-optimization/66142 + * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle non-GIMPLE + values better in memcpy destination handling. Handle non-aliasing + we discover here. + 2015-05-28 Lawrence Velázquez PR target/63810 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 22e6021fb68..ddc74fc274c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-05-28 Richard Biener + + PR tree-optimization/66142 + * gcc.dg/tree-ssa/ssa-fre-44.c: Fixup. + 2015-05-28 Lawrence Velázquez PR target/63810 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-44.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-44.c index 74707b27bbd..7d5f7137295 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-44.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-44.c @@ -39,7 +39,6 @@ f3 (struct B *x, int y) struct A *q = &x[y].u; __builtin_memcpy (&q->x, &p.x, sizeof (float)); __builtin_memcpy (&q->y, &p.y, sizeof (float)); - *q = p; float f = x[y].u.x + x[y].u.y; bar (&p); return f; diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 03be480b13f..9d2345f41c4 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2028,7 +2028,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, lhs = gimple_call_arg (def_stmt, 0); lhs_offset = 0; if (TREE_CODE (lhs) == SSA_NAME) - lhs = SSA_VAL (lhs); + { + lhs = SSA_VAL (lhs); + if (TREE_CODE (lhs) == SSA_NAME) + { + gimple def_stmt = SSA_NAME_DEF_STMT (lhs); + if (gimple_assign_single_p (def_stmt) + && gimple_assign_rhs_code (def_stmt) == ADDR_EXPR) + lhs = gimple_assign_rhs1 (def_stmt); + } + } if (TREE_CODE (lhs) == ADDR_EXPR) { tree tem = get_addr_base_and_unit_offset (TREE_OPERAND (lhs, 0), @@ -2039,6 +2048,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, && tree_fits_uhwi_p (TREE_OPERAND (tem, 1))) { lhs = TREE_OPERAND (tem, 0); + if (TREE_CODE (lhs) == SSA_NAME) + lhs = SSA_VAL (lhs); lhs_offset += tree_to_uhwi (TREE_OPERAND (tem, 1)); } else if (DECL_P (tem)) @@ -2089,10 +2100,15 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, || TREE_OPERAND (lhs, 0) != base))) return (void *)-1; - /* And the access has to be contained within the memcpy destination. */ at = offset / BITS_PER_UNIT; if (TREE_CODE (base) == MEM_REF) at += tree_to_uhwi (TREE_OPERAND (base, 1)); + /* If the access is completely outside of the memcpy destination + area there is no aliasing. */ + if (lhs_offset >= at + maxsize / BITS_PER_UNIT + || lhs_offset + copy_size <= at) + return NULL; + /* And the access has to be contained within the memcpy destination. */ if (lhs_offset > at || lhs_offset + copy_size < at + maxsize / BITS_PER_UNIT) return (void *)-1; -- 2.30.2