OSDN Git Service

PR c++/48292
[pf3gnuchains/gcc-fork.git] / gcc / tree-predcom.c
index 712cc68..2dbd07d 100644 (file)
@@ -1,5 +1,5 @@
 /* Predictive commoning.
-   Copyright (C) 2005, 2007, 2008, 2009, 2010
+   Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -829,7 +829,7 @@ suitable_component_p (struct loop *loop, struct component *comp)
       gcc_assert (dominated_by_p (CDI_DOMINATORS, ba, bp));
       bp = ba;
 
-      if (!DR_IS_READ (a->ref))
+      if (DR_IS_WRITE (a->ref))
        has_write = true;
     }
 
@@ -1192,12 +1192,11 @@ determine_roots_comp (struct loop *loop,
       return;
     }
 
-  qsort (VEC_address (dref, comp->refs), VEC_length (dref, comp->refs),
-        sizeof (dref), order_drefs);
+  VEC_qsort (dref, comp->refs, order_drefs);
 
   FOR_EACH_VEC_ELT (dref, comp->refs, i, a)
     {
-      if (!chain || !DR_IS_READ (a->ref)
+      if (!chain || DR_IS_WRITE (a->ref)
          || double_int_ucmp (uhwi_to_double_int (MAX_DISTANCE),
                              double_int_sub (a->offset, last_ofs)) <= 0)
        {
@@ -1348,11 +1347,8 @@ ref_at_iteration (struct loop *loop, tree ref, int iter)
           && TREE_CODE (ref) != MEM_REF)
     return unshare_expr (ref);
 
-  if (INDIRECT_REF_P (ref)
-      || TREE_CODE (ref) == MEM_REF)
+  if (TREE_CODE (ref) == MEM_REF)
     {
-      /* Take care for MEM_REF and MISALIGNED_INDIRECT_REF at
-         the same time.  */
       ret = unshare_expr (ref);
       idx = TREE_OPERAND (ref, 0);
       idx_p = &TREE_OPERAND (ret, 0);
@@ -1611,7 +1607,7 @@ execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars)
   gcc_assert (chain->type == CT_INVARIANT);
   gcc_assert (!chain->combined);
   FOR_EACH_VEC_ELT (dref, chain->refs, i, a)
-    if (!DR_IS_READ (a->ref))
+    if (DR_IS_WRITE (a->ref))
       n_writes++;
 
   /* If there are no reads in the loop, there is nothing to do.  */
@@ -1627,7 +1623,7 @@ execute_load_motion (struct loop *loop, chain_p chain, bitmap tmp_vars)
       bool is_read = DR_IS_READ (a->ref);
       mark_virtual_ops_for_renaming (a->stmt);
 
-      if (!DR_IS_READ (a->ref))
+      if (DR_IS_WRITE (a->ref))
        {
          n_writes--;
          if (n_writes)
@@ -1672,6 +1668,8 @@ single_nonlooparound_use (tree name)
 
          return NULL;
        }
+      else if (is_gimple_debug (stmt))
+       continue;
       else if (ret != NULL)
        return NULL;
       else
@@ -2445,6 +2443,7 @@ prepare_initializers (struct loop *loop, VEC (chain_p, heap) *chains)
 static bool
 tree_predictive_commoning_loop (struct loop *loop)
 {
+  VEC (loop_p, heap) *loop_nest;
   VEC (data_reference_p, heap) *datarefs;
   VEC (ddr_p, heap) *dependences;
   struct component *components;
@@ -2462,11 +2461,14 @@ tree_predictive_commoning_loop (struct loop *loop)
      dependence relations.  */
   datarefs = VEC_alloc (data_reference_p, heap, 10);
   dependences = VEC_alloc (ddr_p, heap, 10);
-  compute_data_dependences_for_loop (loop, true, &datarefs, &dependences);
+  loop_nest = VEC_alloc (loop_p, heap, 3);
+  compute_data_dependences_for_loop (loop, true, &loop_nest, &datarefs,
+                                    &dependences);
   if (dump_file && (dump_flags & TDF_DETAILS))
     dump_data_dependence_relations (dump_file, dependences);
 
   components = split_data_refs_to_components (loop, datarefs, dependences);
+  VEC_free (loop_p, heap, loop_nest);
   free_dependence_relations (dependences);
   if (!components)
     {