re PR debug/66691 (ICE on valid code at -O3 with -g enabled in simplify_subreg, at...
[gcc.git] / gcc / modulo-sched.c
index 3b62eafe157f15902b98a5203ace9d12afe4a6bf..60b39f81d180f13f77462956c0fae446d3b4bf39 100644 (file)
@@ -1,5 +1,5 @@
 /* Swing Modulo Scheduling implementation.
-   Copyright (C) 2004-2014 Free Software Foundation, Inc.
+   Copyright (C) 2004-2015 Free Software Foundation, Inc.
    Contributed by Ayal Zaks and Mustafa Hagog <zaks,mustafa@il.ibm.com>
 
 This file is part of GCC.
@@ -29,21 +29,41 @@ along with GCC; see the file COPYING3.  If not see
 #include "hard-reg-set.h"
 #include "regs.h"
 #include "function.h"
+#include "profile.h"
 #include "flags.h"
 #include "insn-config.h"
 #include "insn-attr.h"
 #include "except.h"
 #include "recog.h"
+#include "dominance.h"
+#include "cfg.h"
+#include "cfgrtl.h"
+#include "predict.h"
+#include "basic-block.h"
 #include "sched-int.h"
 #include "target.h"
 #include "cfgloop.h"
+#include "alias.h"
+#include "symtab.h"
+#include "tree.h"
+#include "insn-codes.h"
+#include "optabs.h"
+#include "expmed.h"
+#include "dojump.h"
+#include "explow.h"
+#include "calls.h"
+#include "emit-rtl.h"
+#include "varasm.h"
+#include "stmt.h"
 #include "expr.h"
 #include "params.h"
 #include "gcov-io.h"
+#include "sbitmap.h"
+#include "df.h"
 #include "ddg.h"
 #include "tree-pass.h"
 #include "dbgcnt.h"
-#include "df.h"
+#include "loop-unroll.h"
 
 #ifdef INSN_SCHEDULING
 
@@ -212,7 +232,7 @@ static int compute_split_row (sbitmap, int, int, int, ddg_node_ptr);
 static int sms_order_nodes (ddg_ptr, int, int *, int *);
 static void set_node_sched_params (ddg_ptr);
 static partial_schedule_ptr sms_schedule_by_order (ddg_ptr, int, int, int *);
-static void permute_partial_schedule (partial_schedule_ptr, rtx);
+static void permute_partial_schedule (partial_schedule_ptr, rtx_insn *);
 static void generate_prolog_epilog (partial_schedule_ptr, struct loop *,
                                     rtx, rtx);
 static int calculate_stage_count (partial_schedule_ptr, int);
@@ -759,8 +779,7 @@ schedule_reg_moves (partial_schedule_ptr ps)
          move->old_reg = old_reg;
          move->new_reg = gen_reg_rtx (GET_MODE (prev_reg));
          move->num_consecutive_stages = distances[0] && distances[1] ? 2 : 1;
-         move->insn = as_a <rtx_insn *> (gen_move_insn (move->new_reg,
-                                                        copy_rtx (prev_reg)));
+         move->insn = gen_move_insn (move->new_reg, copy_rtx (prev_reg));
          bitmap_clear (move->uses);
 
          prev_reg = move->new_reg;
@@ -876,7 +895,7 @@ reset_sched_times (partial_schedule_ptr ps, int amount)
    row ii-1, and position them right before LAST.  This schedules
    the insns of the loop kernel.  */
 static void
-permute_partial_schedule (partial_schedule_ptr ps, rtx last)
+permute_partial_schedule (partial_schedule_ptr ps, rtx_insn *last)
 {
   int ii = ps->ii;
   int row;
@@ -1451,15 +1470,15 @@ sms_schedule (void)
              if (profile_info && flag_branch_probabilities)
                {
                  fprintf (dump_file, "SMS loop-count ");
-                 fprintf (dump_file, "%"PRId64,
+                 fprintf (dump_file, "%" PRId64,
                           (int64_t) bb->count);
                  fprintf (dump_file, "\n");
                   fprintf (dump_file, "SMS trip-count ");
-                  fprintf (dump_file, "%"PRId64,
+                  fprintf (dump_file, "%" PRId64,
                            (int64_t) trip_count);
                   fprintf (dump_file, "\n");
                  fprintf (dump_file, "SMS profile-sum-max ");
-                 fprintf (dump_file, "%"PRId64,
+                 fprintf (dump_file, "%" PRId64,
                           (int64_t) profile_info->sum_max);
                  fprintf (dump_file, "\n");
                }
@@ -1539,7 +1558,8 @@ sms_schedule (void)
   FOR_EACH_LOOP (loop, 0)
     {
       rtx_insn *head, *tail;
-      rtx count_reg, count_init;
+      rtx count_reg;
+      rtx_insn *count_init;
       int mii, rec_mii, stage_count, min_cycle;
       int64_t loop_count = 0;
       bool opt_sc_p;
@@ -1572,11 +1592,11 @@ sms_schedule (void)
          if (profile_info && flag_branch_probabilities)
            {
              fprintf (dump_file, "SMS loop-count ");
-             fprintf (dump_file, "%"PRId64,
+             fprintf (dump_file, "%" PRId64,
                       (int64_t) bb->count);
              fprintf (dump_file, "\n");
              fprintf (dump_file, "SMS profile-sum-max ");
-             fprintf (dump_file, "%"PRId64,
+             fprintf (dump_file, "%" PRId64,
                       (int64_t) profile_info->sum_max);
              fprintf (dump_file, "\n");
            }
@@ -1589,7 +1609,7 @@ sms_schedule (void)
 
       /* In case of th loop have doloop register it gets special
         handling.  */
-      count_init = NULL_RTX;
+      count_init = NULL;
       if ((count_reg = doloop_register_get (head, tail)))
        {
          basic_block pre_header;
@@ -1603,7 +1623,7 @@ sms_schedule (void)
       if (dump_file && count_init)
         {
           fprintf (dump_file, "SMS const-doloop ");
-          fprintf (dump_file, "%"PRId64,
+          fprintf (dump_file, "%" PRId64,
                     loop_count);
           fprintf (dump_file, "\n");
         }
@@ -1664,9 +1684,9 @@ sms_schedule (void)
                  fprintf (dump_file, "SMS failed... \n");
                  fprintf (dump_file, "SMS sched-failed (stage-count=%d,"
                           " loop-count=", stage_count);
-                 fprintf (dump_file, "%"PRId64, loop_count);
+                 fprintf (dump_file, "%" PRId64, loop_count);
                  fprintf (dump_file, ", trip-count=");
-                 fprintf (dump_file, "%"PRId64, trip_count);
+                 fprintf (dump_file, "%" PRId64, trip_count);
                  fprintf (dump_file, ")\n");
                }
              break;
@@ -1986,9 +2006,7 @@ get_sched_window (partial_schedule_ptr ps, ddg_node_ptr u_node,
      node close to its successors.  */
   if (pss_not_empty && count_succs >= count_preds)
     {
-      int tmp = end;
-      end = start;
-      start = tmp;
+      std::swap (start, end);
       step = -1;
     }
 
@@ -2171,7 +2189,7 @@ sms_schedule_by_order (ddg_ptr g, int mii, int maxii, int *nodes_order)
        {
          int u = nodes_order[i];
          ddg_node_ptr u_node = &ps->g->nodes[u];
-         rtx insn = u_node->insn;
+         rtx_insn *insn = u_node->insn;
 
          if (!NONDEBUG_INSN_P (insn))
            {