fold-const.c (fold_comparsion): Pass OEP_ADDRESS_OF when comparing addresses.
authorJan Hubicka <hubicka@ucw.cz>
Mon, 12 Oct 2015 05:26:47 +0000 (07:26 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 12 Oct 2015 05:26:47 +0000 (05:26 +0000)
* fold-const.c (fold_comparsion): Pass OEP_ADDRESS_OF when comparing
addresses.
(fold_addr_of_array_ref_difference): Likewise.

From-SVN: r228701

gcc/ChangeLog
gcc/fold-const.c

index eff9eeaea0493ade06718d85af1af6167d2a9c8b..7ba2cf9cf65cfde316ee280a15f0cd2c1beef513 100644 (file)
@@ -1,3 +1,9 @@
+2015-10-11  Jan Hubicka  <hubicka@ucw.cz>
+
+       * fold-const.c (fold_comparsion): Pass OEP_ADDRESS_OF when comparing
+       addresses.
+       (fold_addr_of_array_ref_difference): Likewise.
+
 2015-10-11  Jeff Law  <law@redhat.com>
 
        * tree-ssa-threadedge.c (fsm_find_thread_path): Moved from here into
index bdfda9a3cdc129d19aec1457062aa52c6fa9a6d5..de45a2cf4777cf2c6db8e5567a830a7af285ff3f 100644 (file)
@@ -8426,7 +8426,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
 
       /* If we have equivalent bases we might be able to simplify.  */
       if (indirect_base0 == indirect_base1
-         && operand_equal_p (base0, base1, 0))
+         && operand_equal_p (base0, base1,
+                             indirect_base0 ? OEP_ADDRESS_OF : 0))
        {
          /* We can fold this expression to a constant if the non-constant
             offset parts are equal.  */
@@ -8846,7 +8847,7 @@ fold_addr_of_array_ref_difference (location_t loc, tree type,
          && (base_offset = fold_binary_loc (loc, MINUS_EXPR, type,
                                             TREE_OPERAND (base0, 0),
                                             TREE_OPERAND (base1, 0))))
-      || operand_equal_p (base0, base1, 0))
+      || operand_equal_p (base0, base1, OEP_ADDRESS_OF))
     {
       tree op0 = fold_convert_loc (loc, type, TREE_OPERAND (aref0, 1));
       tree op1 = fold_convert_loc (loc, type, TREE_OPERAND (aref1, 1));