re PR tree-optimization/64715 (__builtin_object_size (..., 1) fails to locate subobject)
authorRichard Biener <rguenther@suse.de>
Fri, 20 Mar 2015 12:39:32 +0000 (12:39 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 20 Mar 2015 12:39:32 +0000 (12:39 +0000)
2015-03-20  Richard Biener  <rguenther@suse.de>

PR middle-end/64715
* tree-chrec.c (chrec_fold_poly_cst): Use useless_type_conversion_p
for type comparison and gcc_checking_assert.
(chrec_fold_plus_poly_poly): Likewise.
(chrec_fold_multiply_poly_poly): Likewise.
(chrec_convert_1): Likewise.
* gimplify.c (gimplify_expr): Remove premature folding of
&X + CST to &MEM[&X, CST].

* gcc.dg/pr15347.c: Use -O.
* c-c++-common/pr19807-1.c: Likewise.

From-SVN: r221532

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr19807-1.c
gcc/testsuite/gcc.dg/pr15347.c
gcc/tree-chrec.c

index 33369648c2f88c81e668640dcfecd3e3db941b4a..37f56066ce8f52625f472618fa1596584da11492 100644 (file)
@@ -1,3 +1,14 @@
+2015-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64715
+       * tree-chrec.c (chrec_fold_poly_cst): Use useless_type_conversion_p
+       for type comparison and gcc_checking_assert.
+       (chrec_fold_plus_poly_poly): Likewise.
+       (chrec_fold_multiply_poly_poly): Likewise.
+       (chrec_convert_1): Likewise.
+       * gimplify.c (gimplify_expr): Remove premature folding of
+       &X + CST to &MEM[&X, CST].
+
 2015-03-20  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-inline.c (can_inline_edge_p): Short circuit if inline_failed
index d822913accea99a07d137242b7e1a0b5099825e2..ff0a225c92c5fc3ff67317503ffaa0dd17312ff4 100644 (file)
@@ -8524,23 +8524,6 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
                                post_p, is_gimple_val, fb_rvalue);
            recalculate_side_effects (*expr_p);
            ret = MIN (r0, r1);
-           /* Convert &X + CST to invariant &MEM[&X, CST].  Do this
-              after gimplifying operands - this is similar to how
-              it would be folding all gimplified stmts on creation
-              to have them canonicalized, which is what we eventually
-              should do anyway.  */
-           if (TREE_CODE (TREE_OPERAND (*expr_p, 1)) == INTEGER_CST
-               && is_gimple_min_invariant (TREE_OPERAND (*expr_p, 0)))
-             {
-               *expr_p = build_fold_addr_expr_with_type_loc
-                  (input_location,
-                   fold_build2 (MEM_REF, TREE_TYPE (TREE_TYPE (*expr_p)),
-                                TREE_OPERAND (*expr_p, 0),
-                                fold_convert (ptr_type_node,
-                                              TREE_OPERAND (*expr_p, 1))),
-                   TREE_TYPE (*expr_p));
-               ret = MIN (ret, GS_OK);
-             }
            break;
          }
 
index 7300bb6e17cc19fecab2d8846ec42c55e1d29031..884fb62745911c5b51370e422adde1aad8431ea4 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/64715
+       * gcc.dg/pr15347.c: Use -O.
+       * c-c++-common/pr19807-1.c: Likewise.
+
 2015-03-20  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/volatile13.ad[sb]: New test.
index 92ee2245bfde84043f7c0c4b63f5186f2abc7873..9dc685d6fbfe23180fe173784c02eef6aaa0ccad 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-options "-O" } */
 
 extern void link_error(void);
 int main()
index b95b0ea2a5e2421fb43cba6e2851001616c7a3eb..a75267f7e4b69ae3935540a81c6bbcb964995a86 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do link } */
+/* { dg-options "-O" } */
 
 extern void link_error (void);
 int
index 84ba30e4e92ba353fbc20437e1d3032227cfd1bb..b599c2c3e5e40f75ab0d1e790abe129aa7aa52a2 100644 (file)
@@ -78,8 +78,8 @@ chrec_fold_poly_cst (enum tree_code code,
   gcc_assert (poly);
   gcc_assert (cst);
   gcc_assert (TREE_CODE (poly) == POLYNOMIAL_CHREC);
-  gcc_assert (!is_not_constant_evolution (cst));
-  gcc_assert (type == chrec_type (poly));
+  gcc_checking_assert (!is_not_constant_evolution (cst));
+  gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly)));
 
   switch (code)
     {
@@ -124,10 +124,11 @@ chrec_fold_plus_poly_poly (enum tree_code code,
   gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
   gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
   if (POINTER_TYPE_P (chrec_type (poly0)))
-    gcc_assert (ptrofftype_p (chrec_type (poly1)));
+    gcc_checking_assert (ptrofftype_p (chrec_type (poly1))
+                        && useless_type_conversion_p (type, chrec_type (poly0)));
   else
-    gcc_assert (chrec_type (poly0) == chrec_type (poly1));
-  gcc_assert (type == chrec_type (poly0));
+    gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly0))
+                        && useless_type_conversion_p (type, chrec_type (poly1)));
 
   /*
     {a, +, b}_1 + {c, +, d}_2  ->  {{a, +, b}_1 + c, +, d}_2,
@@ -208,8 +209,8 @@ chrec_fold_multiply_poly_poly (tree type,
   gcc_assert (poly1);
   gcc_assert (TREE_CODE (poly0) == POLYNOMIAL_CHREC);
   gcc_assert (TREE_CODE (poly1) == POLYNOMIAL_CHREC);
-  gcc_assert (chrec_type (poly0) == chrec_type (poly1));
-  gcc_assert (type == chrec_type (poly0));
+  gcc_checking_assert (useless_type_conversion_p (type, chrec_type (poly0))
+                      && useless_type_conversion_p (type, chrec_type (poly1)));
 
   /* {a, +, b}_1 * {c, +, d}_2  ->  {c*{a, +, b}_1, +, d}_2,
      {a, +, b}_2 * {c, +, d}_1  ->  {a*{c, +, d}_1, +, b}_2,
@@ -1352,7 +1353,7 @@ chrec_convert_1 (tree type, tree chrec, gimple at_stmt,
     return chrec;
 
   ct = chrec_type (chrec);
-  if (ct == type)
+  if (useless_type_conversion_p (type, ct))
     return chrec;
 
   if (!evolution_function_is_affine_p (chrec))