OSDN Git Service

PR c++/44703
[pf3gnuchains/gcc-fork.git] / gcc / graphite-sese-to-poly.c
index 9f5ee8a..7f83ffc 100644 (file)
@@ -515,7 +515,7 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule,
   int nb_params = scop_nb_params (scop);
   ppl_Coefficient_t c;
   ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params;
-  Value v;
+  mpz_t v;
 
   gcc_assert (scattering_dimensions >= used_scattering_dimensions);
 
@@ -614,7 +614,7 @@ build_scop_scattering (scop_p scop)
   gimple_bb_p previous_gbb = NULL;
   ppl_Linear_Expression_t static_schedule;
   ppl_Coefficient_t c;
-  Value v;
+  mpz_t v;
 
   mpz_init (v);
   ppl_new_Coefficient (&c);
@@ -665,9 +665,9 @@ build_scop_scattering (scop_p scop)
 
 static void
 add_value_to_dim (ppl_dimension_type d, ppl_Linear_Expression_t expr,
-                 Value k)
+                 mpz_t k)
 {
-  Value val;
+  mpz_t val;
   ppl_Coefficient_t coef;
 
   ppl_new_Coefficient (&coef);
@@ -695,7 +695,7 @@ scan_tree_for_params_right_scev (sese s, tree e, int var,
     {
       loop_p loop = get_loop (var);
       ppl_dimension_type l = sese_loop_depth (s, loop) - 1;
-      Value val;
+      mpz_t val;
 
       /* Scalar evolutions should happen in the sese region.  */
       gcc_assert (sese_loop_depth (s, loop) > 0);
@@ -719,9 +719,9 @@ scan_tree_for_params_right_scev (sese s, tree e, int var,
    linear expression EXPR.  K is the multiplier of the constant.  */
 
 static void
-scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, Value k)
+scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, mpz_t k)
 {
-  Value val;
+  mpz_t val;
   ppl_Coefficient_t coef;
   int v = int_cst_value (cst);
 
@@ -789,7 +789,7 @@ parameter_index_in_region (tree name, sese region)
 
 static void
 scan_tree_for_params (sese s, tree e, ppl_Linear_Expression_t c,
-                     Value k)
+                     mpz_t k)
 {
   if (e == chrec_dont_know)
     return;
@@ -807,7 +807,7 @@ scan_tree_for_params (sese s, tree e, ppl_Linear_Expression_t c,
        {
          if (c)
            {
-             Value val;
+             mpz_t val;
              gcc_assert (host_integerp (TREE_OPERAND (e, 1), 0));
              mpz_init (val);
              mpz_set_si (val, int_cst_value (TREE_OPERAND (e, 1)));
@@ -822,7 +822,7 @@ scan_tree_for_params (sese s, tree e, ppl_Linear_Expression_t c,
        {
          if (c)
            {
-             Value val;
+             mpz_t val;
              gcc_assert (host_integerp (TREE_OPERAND (e, 0), 0));
              mpz_init (val);
              mpz_set_si (val, int_cst_value (TREE_OPERAND (e, 0)));
@@ -904,7 +904,7 @@ scan_tree_for_params (sese s, tree e, ppl_Linear_Expression_t c,
        if (c)
          {
            ppl_Coefficient_t coef;
-           Value minus_one;
+           mpz_t minus_one;
 
            ppl_subtract_Linear_Expression_from_Linear_Expression (c,
                                                                   tmp_expr);
@@ -961,7 +961,7 @@ find_params_in_bb (sese region, gimple_bb_p gbb)
   data_reference_p dr;
   gimple stmt;
   loop_p loop = GBB_BB (gbb)->loop_father;
-  Value one;
+  mpz_t one;
 
   mpz_init (one);
   mpz_set_si (one, 1);
@@ -996,7 +996,7 @@ find_scop_parameters (scop_p scop)
   unsigned i;
   sese region = SCOP_REGION (scop);
   struct loop *loop;
-  Value one;
+  mpz_t one;
 
   mpz_init (one);
   mpz_set_si (one, 1);
@@ -1044,7 +1044,7 @@ add_upper_bounds_from_estimated_nit (scop_p scop, double_int nit,
                                     ppl_dimension_type dim,
                                     ppl_Linear_Expression_t ub_expr)
 {
-  Value val;
+  mpz_t val;
   ppl_Linear_Expression_t nb_iters_le;
   ppl_Polyhedron_t pol;
   ppl_Coefficient_t coef;
@@ -1165,7 +1165,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
     }
   else if (!chrec_contains_undetermined (nb_iters))
     {
-      Value one;
+      mpz_t one;
       ppl_Constraint_t ub;
       ppl_Linear_Expression_t ub_expr;
       double_int nit;
@@ -1209,7 +1209,7 @@ build_loop_iteration_domains (scop_p scop, struct loop *loop,
 static ppl_Linear_Expression_t
 create_linear_expr_from_tree (poly_bb_p pbb, tree t)
 {
-  Value one;
+  mpz_t one;
   ppl_Linear_Expression_t res;
   ppl_dimension_type dim;
   sese region = SCOP_REGION (PBB_SCOP (pbb));
@@ -1265,7 +1265,7 @@ static void
 add_condition_to_domain (ppl_Pointset_Powerset_C_Polyhedron_t ps, gimple stmt,
                         poly_bb_p pbb, enum tree_code code)
 {
-  Value v;
+  mpz_t v;
   ppl_Coefficient_t c;
   ppl_Linear_Expression_t left, right;
   ppl_Constraint_t cstr;
@@ -1328,8 +1328,7 @@ add_condition_to_pbb (poly_bb_p pbb, gimple stmt, enum tree_code code)
        (&right, left);
       add_condition_to_domain (left, stmt, pbb, LT_EXPR);
       add_condition_to_domain (right, stmt, pbb, GT_EXPR);
-      ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (left,
-                                                              right);
+      ppl_Pointset_Powerset_C_Polyhedron_upper_bound_assign (left, right);
       ppl_delete_Pointset_Powerset_C_Polyhedron (right);
     }
   else
@@ -1344,12 +1343,11 @@ add_conditions_to_domain (poly_bb_p pbb)
   unsigned int i;
   gimple stmt;
   gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
-  VEC (gimple, heap) *conditions = GBB_CONDITIONS (gbb);
 
-  if (VEC_empty (gimple, conditions))
+  if (VEC_empty (gimple, GBB_CONDITIONS (gbb)))
     return;
 
-  for (i = 0; VEC_iterate (gimple, conditions, i, stmt); i++)
+  for (i = 0; VEC_iterate (gimple, GBB_CONDITIONS (gbb), i, stmt); i++)
     switch (gimple_code (stmt))
       {
       case GIMPLE_COND:
@@ -1357,7 +1355,7 @@ add_conditions_to_domain (poly_bb_p pbb)
            enum tree_code code = gimple_cond_code (stmt);
 
            /* The conditions for ELSE-branches are inverted.  */
-           if (VEC_index (gimple, gbb->condition_cases, i) == NULL)
+           if (!VEC_index (gimple, GBB_CONDITION_CASES (gbb), i))
              code = invert_tree_comparison (code, false);
 
            add_condition_to_pbb (pbb, stmt, code);
@@ -1381,21 +1379,28 @@ struct bsc
   sese region;
 };
 
-/* Returns non NULL when BB has a single predecessor and the last
-   statement of that predecessor is a COND_EXPR.  */
+/* Returns a COND_EXPR statement when BB has a single predecessor, the
+   edge between BB and its predecessor is not a loop exit edge, and
+   the last statement of the single predecessor is a COND_EXPR.  */
 
 static gimple
-single_pred_cond (basic_block bb)
+single_pred_cond_non_loop_exit (basic_block bb)
 {
   if (single_pred_p (bb))
     {
       edge e = single_pred_edge (bb);
       basic_block pred = e->src;
-      gimple stmt = last_stmt (pred);
+      gimple stmt;
+
+      if (loop_depth (pred->loop_father) > loop_depth (bb->loop_father))
+       return NULL;
+
+      stmt = last_stmt (pred);
 
       if (stmt && gimple_code (stmt) == GIMPLE_COND)
        return stmt;
     }
+
   return NULL;
 }
 
@@ -1409,12 +1414,14 @@ build_sese_conditions_before (struct dom_walk_data *dw_data,
   struct bsc *data = (struct bsc *) dw_data->global_data;
   VEC (gimple, heap) **conditions = data->conditions;
   VEC (gimple, heap) **cases = data->cases;
-  gimple_bb_p gbb = gbb_from_bb (bb);
-  gimple stmt = single_pred_cond (bb);
+  gimple_bb_p gbb;
+  gimple stmt;
 
   if (!bb_in_sese_p (bb, data->region))
     return;
 
+  stmt = single_pred_cond_non_loop_exit (bb);
+
   if (stmt)
     {
       edge e = single_pred_edge (bb);
@@ -1427,6 +1434,8 @@ build_sese_conditions_before (struct dom_walk_data *dw_data,
        VEC_safe_push (gimple, heap, *cases, NULL);
     }
 
+  gbb = gbb_from_bb (bb);
+
   if (gbb)
     {
       GBB_CONDITIONS (gbb) = VEC_copy (gimple, heap, *conditions);
@@ -1448,7 +1457,7 @@ build_sese_conditions_after (struct dom_walk_data *dw_data,
   if (!bb_in_sese_p (bb, data->region))
     return;
 
-  if (single_pred_cond (bb))
+  if (single_pred_cond_non_loop_exit (bb))
     {
       VEC_pop (gimple, *conditions);
       VEC_pop (gimple, *cases);
@@ -1651,7 +1660,7 @@ pdr_add_memory_accesses (ppl_Polyhedron_t accesses, data_reference_p dr,
                         poly_bb_p pbb)
 {
   int i, nb_subscripts = DR_NUM_DIMENSIONS (dr);
-  Value v;
+  mpz_t v;
   scop_p scop = PBB_SCOP (pbb);
   sese region = SCOP_REGION (scop);
 
@@ -1769,10 +1778,11 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
                                                            accesses);
   ppl_delete_Polyhedron (accesses);
 
-  if (dr->aux)
-    dr_base_object_set = ((base_alias_pair *)(dr->aux))->base_obj_set;
+  gcc_assert (dr->aux);
+  dr_base_object_set = ((base_alias_pair *)(dr->aux))->base_obj_set;
 
-  new_poly_dr (pbb, dr_base_object_set, accesses_ps, DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
+  new_poly_dr (pbb, dr_base_object_set, accesses_ps,
+              DR_IS_READ (dr) ? PDR_READ : PDR_WRITE,
               dr, DR_NUM_DIMENSIONS (dr));
 }
 
@@ -1914,8 +1924,8 @@ build_alias_set_optimal_p (VEC (data_reference_p, heap) *drs)
       data_reference_p dr = VEC_index (data_reference_p, drs, i);
       base_alias_pair *bap;
 
-      if (dr->aux)
-       bap = (base_alias_pair *)(dr->aux);
+      gcc_assert (dr->aux);
+      bap = (base_alias_pair *)(dr->aux);
 
       bap->alias_set = XNEW (int);
       *(bap->alias_set) = g->vertices[i].component + 1;
@@ -1993,8 +2003,8 @@ build_base_obj_set_for_drs (VEC (data_reference_p, heap) *drs)
       data_reference_p dr = VEC_index (data_reference_p, drs, i);
       base_alias_pair *bap;
 
-      if (dr->aux)
-       bap = (base_alias_pair *)(dr->aux);
+      gcc_assert (dr->aux);
+      bap = (base_alias_pair *)(dr->aux);
 
       bap->base_obj_set = g->vertices[i].component + 1;
     }
@@ -2924,6 +2934,7 @@ scop_canonicalize_loops (scop_p scop)
 /* Can all ivs be represented by a signed integer?
    As CLooG might generate negative values in its expressions, signed loop ivs
    are required in the backend. */
+
 static bool
 scop_ivs_can_be_represented (scop_p scop)
 {
@@ -2941,7 +2952,7 @@ scop_ivs_can_be_represented (scop_p scop)
       if (!loop->single_iv)
        continue;
 
-      type = TREE_TYPE(loop->single_iv);
+      type = TREE_TYPE (loop->single_iv);
       precision = TYPE_PRECISION (type);
 
       if (TYPE_UNSIGNED (type)