re PR ipa/65270 (issues with merging memory accesses from different code paths)
authorRichard Biener <rguenther@suse.de>
Thu, 12 Mar 2015 13:02:42 +0000 (13:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 12 Mar 2015 13:02:42 +0000 (13:02 +0000)
2015-03-12  Richard Biener  <rguenther@suse.de>

PR middle-end/65270
* fold-const.c (operand_equal_p): Fix ordering of resetting
OEP_ADDRESS_OF and checking for it in the [TARGET_]MEM_REF case.

From-SVN: r221386

gcc/ChangeLog
gcc/fold-const.c

index 590099891206ebc8cd9ff54a601e3988559e4a4d..35c6a95c51cb1e0feb189b8ecd399b8bba2afdb9 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-12  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/65270
+       * fold-const.c (operand_equal_p): Fix ordering of resetting
+       OEP_ADDRESS_OF and checking for it in the [TARGET_]MEM_REF case.
+
 2015-03-12  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        * config/s390/s390.c (s390_reorg): Move code to output nops after label
index 915d6395382312f520f3c8fd5728c402e33cf725..6d085b185895f715d99a53a9e706295aa983d52a 100644 (file)
@@ -2934,21 +2934,12 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
          return OP_SAME (0);
 
        case TARGET_MEM_REF:
-         flags &= ~(OEP_CONSTANT_ADDRESS_OF|OEP_ADDRESS_OF);
-         /* Require equal extra operands and then fall through to MEM_REF
-            handling of the two common operands.  */
-         if (!OP_SAME_WITH_NULL (2)
-             || !OP_SAME_WITH_NULL (3)
-             || !OP_SAME_WITH_NULL (4))
-           return 0;
-         /* Fallthru.  */
        case MEM_REF:
-         flags &= ~(OEP_CONSTANT_ADDRESS_OF|OEP_ADDRESS_OF);
          /* Require equal access sizes, and similar pointer types.
             We can have incomplete types for array references of
             variable-sized arrays from the Fortran frontend
             though.  Also verify the types are compatible.  */
-         return ((TYPE_SIZE (TREE_TYPE (arg0)) == TYPE_SIZE (TREE_TYPE (arg1))
+         if (!((TYPE_SIZE (TREE_TYPE (arg0)) == TYPE_SIZE (TREE_TYPE (arg1))
                   || (TYPE_SIZE (TREE_TYPE (arg0))
                       && TYPE_SIZE (TREE_TYPE (arg1))
                       && operand_equal_p (TYPE_SIZE (TREE_TYPE (arg0)),
@@ -2963,8 +2954,15 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags)
                          && (MR_DEPENDENCE_BASE (arg0)
                              == MR_DEPENDENCE_BASE (arg1))
                          && (TYPE_ALIGN (TREE_TYPE (arg0))
-                             == TYPE_ALIGN (TREE_TYPE (arg1)))))
-                 && OP_SAME (0) && OP_SAME (1));
+                           == TYPE_ALIGN (TREE_TYPE (arg1)))))))
+           return 0;
+         flags &= ~(OEP_CONSTANT_ADDRESS_OF|OEP_ADDRESS_OF);
+         return (OP_SAME (0) && OP_SAME (1)
+                 /* TARGET_MEM_REF require equal extra operands.  */
+                 && (TREE_CODE (arg0) != TARGET_MEM_REF
+                     || (OP_SAME_WITH_NULL (2)
+                         && OP_SAME_WITH_NULL (3)
+                         && OP_SAME_WITH_NULL (4))));
 
        case ARRAY_REF:
        case ARRAY_RANGE_REF: