]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Guenther <rguenther@suse.de>
Mon, 18 Apr 2011 14:02:22 +0000 (14:02 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 18 Apr 2011 14:02:22 +0000 (14:02 +0000)
2011-04-18  Richard Guenther  <rguenther@suse.de>

Backported from 4.6 branch
2011-03-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/48035
* init.c (build_zero_init_1): Extracted from build_zero_init.
Add FIELD_SIZE argument, if non-NULL and field bit_position
as not smaller than that, don't add that field's initializer.
Pass DECL_SIZE as last argument to build_zero_init_1
for DECL_FIELD_IS_BASE fields.
(build_zero_init): Use build_zero_init_1.

* g++.dg/inherit/virtual8.C: New test.

2011-03-05  Zdenek Dvorak  <ook@ucw.cz>

PR rtl-optimization/47899
* cfgloopmanip.c (fix_bb_placements): Fix first argument
to flow_loop_nested_p when moving the loop upward.

* gcc.dg/pr47899.c: New test.

2011-03-15  Richard Guenther  <rguenther@suse.de>

PR middle-end/48031
* fold-const.c (fold_indirect_ref_1): Do not create new variable-sized
or variable-indexed array accesses when in gimple form.

From-SVN: r172647

gcc/ChangeLog
gcc/cfgloopmanip.c
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/fold-const.c
gcc/testsuite/ChangeLog

index d881fbcdeff95a6e7f7896a2e1d31446233859bf..84eb843a694b01b987394caa48bc9ad31ede7c59 100644 (file)
@@ -1,3 +1,18 @@
+2011-04-18  Richard Guenther  <rguenther@suse.de>
+
+       Backported from 4.6 branch
+       2011-03-05  Zdenek Dvorak  <ook@ucw.cz>
+
+       PR rtl-optimization/47899
+       * cfgloopmanip.c (fix_bb_placements): Fix first argument
+       to flow_loop_nested_p when moving the loop upward.
+
+       2011-03-15  Richard Guenther  <rguenther@suse.de>
+       PR middle-end/48031
+       * fold-const.c (fold_indirect_ref_1): Do not create new variable-sized
+       or variable-indexed array accesses when in gimple form.
+
 2011-04-16  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * config/pa/pa.h (REGISTER_MOVE_COST): Increase to 18 cost of
index d4e5518b4be8907f28307a4eccd6c50950cede0c..8f4e7375488c76f33203cbb6d0054a2d9115579d 100644 (file)
@@ -174,7 +174,7 @@ fix_bb_placements (basic_block from,
 {
   sbitmap in_queue;
   basic_block *queue, *qtop, *qbeg, *qend;
-  struct loop *base_loop;
+  struct loop *base_loop, *target_loop;
   edge e;
 
   /* We pass through blocks back-reachable from FROM, testing whether some
@@ -214,12 +214,14 @@ fix_bb_placements (basic_block from,
          /* Subloop header, maybe move the loop upward.  */
          if (!fix_loop_placement (from->loop_father))
            continue;
+         target_loop = loop_outer (from->loop_father);
        }
       else
        {
          /* Ordinary basic block.  */
          if (!fix_bb_placement (from))
            continue;
+         target_loop = from->loop_father;
        }
 
       FOR_EACH_EDGE (e, ei, from->succs)
@@ -248,9 +250,12 @@ fix_bb_placements (basic_block from,
              && (nca == base_loop
                  || nca != pred->loop_father))
            pred = pred->loop_father->header;
-         else if (!flow_loop_nested_p (from->loop_father, pred->loop_father))
+         else if (!flow_loop_nested_p (target_loop, pred->loop_father))
            {
-             /* No point in processing it.  */
+             /* If PRED is already higher in the loop hierarchy than the
+                TARGET_LOOP to that we moved FROM, the change of the position
+                of FROM does not affect the position of PRED, so there is no
+                point in processing it.  */
              continue;
            }
 
index 7a4d367ce5558d1579240469e145afa0dd763fba..2a4dbb826c6399923b9412cc8790fb79cdbdd5e9 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-18  Richard Guenther  <rguenther@suse.de>
+
+       Backported from 4.6 branch 
+       2011-03-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/48035
+       * init.c (build_zero_init_1): Extracted from build_zero_init.
+       Add FIELD_SIZE argument, if non-NULL and field bit_position
+       as not smaller than that, don't add that field's initializer.
+       Pass DECL_SIZE as last argument to build_zero_init_1
+       for DECL_FIELD_IS_BASE fields.
+       (build_zero_init): Use build_zero_init_1.
+
 2011-03-28  Jason Merrill  <jason@redhat.com>
 
        Revert:
index f3ddfc4655ae960050203da8f4e3e9ab0bcf9dfc..bb75eda68074a0a14fdb8fa322dc80e66830c9c3 100644 (file)
@@ -143,10 +143,13 @@ initialize_vtbl_ptrs (tree addr)
    is the number of elements in the array.  If STATIC_STORAGE_P is
    TRUE, initializers are only generated for entities for which
    zero-initialization does not simply mean filling the storage with
-   zero bytes.  */
+   zero bytes.  FIELD_SIZE, if non-NULL, is the bit size of the field,
+   subfields with bit positions at or above that bit size shouldn't
+   be added.  */
 
-tree
-build_zero_init (tree type, tree nelts, bool static_storage_p)
+static tree
+build_zero_init_1 (tree type, tree nelts, bool static_storage_p,
+                  tree field_size)
 {
   tree init = NULL_TREE;
 
@@ -191,15 +194,32 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
          if (TREE_CODE (field) != FIELD_DECL)
            continue;
 
+         /* Don't add virtual bases for base classes if they are beyond
+            the size of the current field, that means it is present
+            somewhere else in the object.  */
+         if (field_size)
+           {
+             tree bitpos = bit_position (field);
+             if (TREE_CODE (bitpos) == INTEGER_CST
+                 && !tree_int_cst_lt (bitpos, field_size))
+               continue;
+           }
+
          /* Note that for class types there will be FIELD_DECLs
             corresponding to base classes as well.  Thus, iterating
             over TYPE_FIELDs will result in correct initialization of
             all of the subobjects.  */
          if (!static_storage_p || !zero_init_p (TREE_TYPE (field)))
            {
-             tree value = build_zero_init (TREE_TYPE (field),
-                                           /*nelts=*/NULL_TREE,
-                                           static_storage_p);
+             tree new_field_size
+               = (DECL_FIELD_IS_BASE (field)
+                  && DECL_SIZE (field)
+                  && TREE_CODE (DECL_SIZE (field)) == INTEGER_CST)
+                 ? DECL_SIZE (field) : NULL_TREE;
+             tree value = build_zero_init_1 (TREE_TYPE (field),
+                                             /*nelts=*/NULL_TREE,
+                                             static_storage_p,
+                                             new_field_size);
              if (value)
                CONSTRUCTOR_APPEND_ELT(v, field, value);
            }
@@ -247,9 +267,9 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
            ce->index = build2 (RANGE_EXPR, sizetype, size_zero_node,
                                max_index);
 
-         ce->value = build_zero_init (TREE_TYPE (type),
-                                      /*nelts=*/NULL_TREE,
-                                      static_storage_p);
+         ce->value = build_zero_init_1 (TREE_TYPE (type),
+                                        /*nelts=*/NULL_TREE,
+                                        static_storage_p, NULL_TREE);
        }
 
       /* Build a constructor to contain the initializations.  */
@@ -267,6 +287,24 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
   return init;
 }
 
+/* Return an expression for the zero-initialization of an object with
+   type T.  This expression will either be a constant (in the case
+   that T is a scalar), or a CONSTRUCTOR (in the case that T is an
+   aggregate), or NULL (in the case that T does not require
+   initialization).  In either case, the value can be used as
+   DECL_INITIAL for a decl of the indicated TYPE; it is a valid static
+   initializer. If NELTS is non-NULL, and TYPE is an ARRAY_TYPE, NELTS
+   is the number of elements in the array.  If STATIC_STORAGE_P is
+   TRUE, initializers are only generated for entities for which
+   zero-initialization does not simply mean filling the storage with
+   zero bytes.  */
+
+tree
+build_zero_init (tree type, tree nelts, bool static_storage_p)
+{
+  return build_zero_init_1 (type, nelts, static_storage_p, NULL_TREE);
+}
+
 /* Return a suitable initializer for value-initializing an object of type
    TYPE, as described in [dcl.init].  */
 
index 0bd9c34fb412b24171456643d46c847e17a3f8c1..799a3cb41d2443fd764cfb1c76994e5b1ebf8095 100644 (file)
@@ -16074,12 +16074,17 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
        }
       /* *(foo *)&fooarray => fooarray[0] */
       else if (TREE_CODE (optype) == ARRAY_TYPE
-              && type == TREE_TYPE (optype))
+              && type == TREE_TYPE (optype)
+              && (!in_gimple_form
+                  || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
        {
          tree type_domain = TYPE_DOMAIN (optype);
          tree min_val = size_zero_node;
          if (type_domain && TYPE_MIN_VALUE (type_domain))
            min_val = TYPE_MIN_VALUE (type_domain);
+         if (in_gimple_form
+             && TREE_CODE (min_val) != INTEGER_CST)
+           return NULL_TREE;
          op0 = build4 (ARRAY_REF, type, op, min_val, NULL_TREE, NULL_TREE);
          SET_EXPR_LOCATION (op0, loc);
          return op0;
@@ -16150,7 +16155,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
 
   /* *(foo *)fooarrptr => (*fooarrptr)[0] */
   if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
-      && type == TREE_TYPE (TREE_TYPE (subtype)))
+      && type == TREE_TYPE (TREE_TYPE (subtype))
+      && (!in_gimple_form
+         || TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST))
     {
       tree type_domain;
       tree min_val = size_zero_node;
@@ -16158,6 +16165,9 @@ fold_indirect_ref_1 (location_t loc, tree type, tree op0)
       type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
       if (type_domain && TYPE_MIN_VALUE (type_domain))
        min_val = TYPE_MIN_VALUE (type_domain);
+      if (in_gimple_form
+         && TREE_CODE (min_val) != INTEGER_CST)
+       return NULL_TREE;
       op0 = build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE);
       SET_EXPR_LOCATION (op0, loc);
       return op0;
index 859fc8a6b5140f51afdd92f8f297ab466a228535..36dd99a9c66d770bf0bc99b2c7b9f5899124feb5 100644 (file)
@@ -1,3 +1,16 @@
+2011-04-18  Richard Guenther  <rguenther@suse.de>
+
+       Backported from 4.6 branch 
+       2011-03-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/48035
+       * g++.dg/inherit/virtual8.C: New test.
+
+       2011-03-05  Zdenek Dvorak  <ook@ucw.cz>
+
+       PR rtl-optimization/47899
+       * gcc.dg/pr47899.c: New test.
+
 2011-04-16  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from 4.6 branch