From 7a667e6491f0df391bb19839b580f33b54088bf3 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sat, 16 Dec 2017 14:09:04 +0000 Subject: [PATCH] Minor vn_reference_lookup_3 tweak The repeated checks for MEM_REF made this code hard to convert to poly_ints as-is. Hopefully the new structure also makes it clearer at a glance what the two cases are. 2017-12-16 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated checks for MEM_REF. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r255742 --- gcc/ChangeLog | 7 +++++++ gcc/tree-ssa-sccvn.c | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a9e8ec1eee..843f4927828 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-12-16 Richard Sandiford + Alan Hayward + David Sherwood + + * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated + checks for MEM_REF. + 2017-12-16 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 63a3db99d03..b6f23f8af8c 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2348,19 +2348,19 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, copy_size = tree_to_uhwi (gimple_call_arg (def_stmt, 2)); /* The bases of the destination and the references have to agree. */ - if ((TREE_CODE (base) != MEM_REF - && !DECL_P (base)) - || (TREE_CODE (base) == MEM_REF - && (TREE_OPERAND (base, 0) != lhs - || !tree_fits_uhwi_p (TREE_OPERAND (base, 1)))) - || (DECL_P (base) - && (TREE_CODE (lhs) != ADDR_EXPR - || TREE_OPERAND (lhs, 0) != base))) - return (void *)-1; - at = offset / BITS_PER_UNIT; if (TREE_CODE (base) == MEM_REF) - at += tree_to_uhwi (TREE_OPERAND (base, 1)); + { + if (TREE_OPERAND (base, 0) != lhs + || !tree_fits_uhwi_p (TREE_OPERAND (base, 1))) + return (void *) -1; + at += tree_to_uhwi (TREE_OPERAND (base, 1)); + } + else if (!DECL_P (base) + || TREE_CODE (lhs) != ADDR_EXPR + || TREE_OPERAND (lhs, 0) != base) + return (void *)-1; + /* If the access is completely outside of the memcpy destination area there is no aliasing. */ if (lhs_offset >= at + maxsize / BITS_PER_UNIT -- 2.30.2