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 7a9e8ec1eeeeeb969acc3bc1635c0f84e4a9fcf1..843f4927828df5154851d1f35e3d29b8cdca130e 100644 (file)
@@ -1,3 +1,10 @@
+2017-12-16  Richard Sandiford  <richard.sandiford@linaro.org>
+           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>
index 63a3db99d03fd9c332a3a875048cb4da7c76816e..b6f23f8af8c46226271e05aafa204f263a1d235a 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