Minor vn_reference_lookup_3 tweak
authorRichard Sandiford <richard.sandiford@linaro.org>
Sat, 16 Dec 2017 14:09:04 +0000 (14:09 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Sat, 16 Dec 2017 14:09:04 +0000 (14:09 +0000)
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  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated
checks for MEM_REF.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r255742

gcc/ChangeLog
gcc/tree-ssa-sccvn.c

index 7a9e8ec..843f492 100644 (file)
@@ -2,6 +2,13 @@
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
 
+       * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid repeated
+       checks for MEM_REF.
+
+2017-12-16  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
        * doc/generic.texi (VEC_SERIES_EXPR): Document.
        * doc/md.texi (vec_series@var{m}): Document.
        * tree.def (VEC_SERIES_EXPR): New tree code.
index 63a3db9..b6f23f8 100644 (file)
@@ -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