fold-const.c (fold_binary_loc): Preserve side-effects of X - X when simplifying to 0.
authorRichard Biener <rguenther@suse.de>
Thu, 23 Oct 2014 08:25:55 +0000 (08:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 23 Oct 2014 08:25:55 +0000 (08:25 +0000)
2014-10-22  Richard Biener  <rguenther@suse.de>

* fold-const.c (fold_binary_loc): Preserve side-effects of
X - X when simplifying to 0.
* stor-layout.c (finish_bitfield_representative): Strip
side-effects of evaluating the difference of two DECL_FIELD_OFFSET.

From-SVN: r216575

gcc/ChangeLog
gcc/fold-const.c
gcc/stor-layout.c

index 5bc8b642a67fea6d981bbebcfac023c8430c48c7..fa3a9cce7bf1333d626e99e0aad39fc948a2cadd 100644 (file)
@@ -1,3 +1,10 @@
+2014-10-23  Richard Biener  <rguenther@suse.de>
+
+       * fold-const.c (fold_binary_loc): Preserve side-effects of
+       X - X when simplifying to 0.
+       * stor-layout.c (finish_bitfield_representative): Strip
+       side-effects of evaluating the difference of two DECL_FIELD_OFFSET.
+
 2014-10-22  Richard Biener  <rguenther@suse.de>
            Tobias Burnus <burnus@net-b.de>
 
index 1e7e9322d1718fed3fc89b18e48367dda59f3e6e..d70658c32d516f65b28fa1d028a5cca6ef32b0c8 100644 (file)
@@ -10749,7 +10749,7 @@ fold_binary_loc (location_t loc,
 
       if ((!FLOAT_TYPE_P (type) || !HONOR_NANS (TYPE_MODE (type)))
          && operand_equal_p (arg0, arg1, 0))
-       return build_zero_cst (type);
+       return omit_one_operand_loc (loc, type, build_zero_cst (type), arg0);
 
       /* A - B -> A + (-B) if B is easily negatable.  */
       if (negate_expr_p (arg1)
index 237cf6926e29bd65d616ef8eb0d90627081d105e..9f0064bb861701ae53292bc6e4418932fd4908cb 100644 (file)
@@ -1860,6 +1860,8 @@ finish_bitfield_representative (tree repr, tree field)
 
   size = size_diffop (DECL_FIELD_OFFSET (field),
                      DECL_FIELD_OFFSET (repr));
+  while (TREE_CODE (size) == COMPOUND_EXPR)
+    size = TREE_OPERAND (size, 1);
   gcc_assert (tree_fits_uhwi_p (size));
   bitsize = (tree_to_uhwi (size) * BITS_PER_UNIT
             + tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))