re PR debug/66691 (ICE on valid code at -O3 with -g enabled in simplify_subreg, at...
[gcc.git] / gcc / sel-sched.c
index e755a19428433afeadb76de7c21bf7c3d9240a98..be5d1d12e899e87e8958568ca03ae3236ee9db9c 100644 (file)
@@ -1,5 +1,5 @@
 /* Instruction scheduling pass.  Selective scheduler and pipeliner.
-   Copyright (C) 2006-2014 Free Software Foundation, Inc.
+   Copyright (C) 2006-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -25,11 +25,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm_p.h"
 #include "hard-reg-set.h"
 #include "regs.h"
-#include "hashtab.h"
-#include "hash-set.h"
-#include "vec.h"
-#include "machmode.h"
-#include "input.h"
 #include "function.h"
 #include "predict.h"
 #include "dominance.h"
@@ -45,7 +40,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "target.h"
 #include "output.h"
 #include "sched-int.h"
-#include "ggc.h"
+#include "symtab.h"
 #include "tree.h"
 #include "langhooks.h"
 #include "rtlhooks-def.h"
@@ -611,7 +606,7 @@ advance_one_cycle (fence_t fence)
 /* Returns true when SUCC in a fallthru bb of INSN, possibly
    skipping empty basic blocks.  */
 static bool
-in_fallthru_bb_p (rtx insn, rtx succ)
+in_fallthru_bb_p (rtx_insn *insn, rtx succ)
 {
   basic_block bb = BLOCK_FOR_INSN (insn);
   edge e;
@@ -822,9 +817,7 @@ count_occurrences_equiv (const_rtx what, const_rtx where)
        {
          /* Bail out if mode is different or more than one register is
             used.  */
-         if (GET_MODE (x) != GET_MODE (what)
-             || (HARD_REGISTER_P (x)
-                 && hard_regno_nregs[REGNO (x)][GET_MODE (x)] > 1))
+         if (GET_MODE (x) != GET_MODE (what) || REG_NREGS (x) > 1)
            return 0;
          count += 1;
        }
@@ -860,7 +853,7 @@ create_insn_rtx_with_rhs (vinsn_t vi, rtx rhs_rtx)
 
   lhs_rtx = copy_rtx (VINSN_LHS (vi));
 
-  pattern = gen_rtx_SET (VOIDmode, lhs_rtx, rhs_rtx);
+  pattern = gen_rtx_SET (lhs_rtx, rhs_rtx);
   insn_rtx = create_insn_rtx_from_pattern (pattern, NULL_RTX);
 
   return insn_rtx;
@@ -941,7 +934,7 @@ create_insn_rtx_with_lhs (vinsn_t vi, rtx lhs_rtx)
 
   rhs_rtx = copy_rtx (VINSN_RHS (vi));
 
-  pattern = gen_rtx_SET (VOIDmode, lhs_rtx, rhs_rtx);
+  pattern = gen_rtx_SET (lhs_rtx, rhs_rtx);
   insn_rtx = create_insn_rtx_from_pattern (pattern, NULL_RTX);
 
   return insn_rtx;
@@ -1044,7 +1037,6 @@ get_reg_class (rtx_insn *insn)
   return NO_REGS;
 }
 
-#ifdef HARD_REGNO_RENAME_OK
 /* Calculate HARD_REGNO_RENAME_OK data for REGNO.  */
 static void
 init_hard_regno_rename (int regno)
@@ -1063,14 +1055,12 @@ init_hard_regno_rename (int regno)
         SET_HARD_REG_BIT (sel_hrd.regs_for_rename[regno], cur_reg);
     }
 }
-#endif
 
 /* A wrapper around HARD_REGNO_RENAME_OK that will look into the hard regs
    data first.  */
 static inline bool
 sel_hard_regno_rename_ok (int from ATTRIBUTE_UNUSED, int to ATTRIBUTE_UNUSED)
 {
-#ifdef HARD_REGNO_RENAME_OK
   /* Check whether this is all calculated.  */
   if (TEST_HARD_REG_BIT (sel_hrd.regs_for_rename[from], from))
     return TEST_HARD_REG_BIT (sel_hrd.regs_for_rename[from], to);
@@ -1078,9 +1068,6 @@ sel_hard_regno_rename_ok (int from ATTRIBUTE_UNUSED, int to ATTRIBUTE_UNUSED)
   init_hard_regno_rename (from);
 
   return TEST_HARD_REG_BIT (sel_hrd.regs_for_rename[from], to);
-#else
-  return true;
-#endif
 }
 
 /* Calculate set of registers that are capable of holding MODE.  */
@@ -1856,7 +1843,7 @@ create_speculation_check (expr_t c_expr, ds_t check_ds, insn_t orig_insn)
 
 /* True when INSN is a "regN = regN" copy.  */
 static bool
-identical_copy_p (rtx insn)
+identical_copy_p (rtx_insn *insn)
 {
   rtx lhs, rhs, pat;
 
@@ -2113,7 +2100,7 @@ implicit_clobber_conflict_p (insn_t through_insn, expr_t expr)
 
   /* Make a new insn with it.  */
   rhs = copy_rtx (VINSN_RHS (EXPR_VINSN (expr)));
-  pat = gen_rtx_SET (VOIDmode, reg, rhs);
+  pat = gen_rtx_SET (reg, rhs);
   start_sequence ();
   insn = emit_insn (pat);
   end_sequence ();
@@ -4145,16 +4132,12 @@ invoke_reorder_hooks (fence_t fence)
       for (i = 0, n = ready.n_ready; i < n; i++)
         if (EXPR_INSN_RTX (vec[i]) != arr[i])
           {
-            expr_t tmp;
-
             for (j = i; j < n; j++)
               if (EXPR_INSN_RTX (vec[j]) == arr[i])
                 break;
             gcc_assert (j < n);
 
-            tmp = vec[i];
-            vec[i] = vec[j];
-            vec[j] = tmp;
+           std::swap (vec[i], vec[j]);
           }
     }
 
@@ -4613,15 +4596,12 @@ create_block_for_bookkeeping (edge e1, edge e2)
            {
              sel_global_bb_info_def gbi;
              sel_region_bb_info_def rbi;
-             int i;
 
              if (sched_verbose >= 2)
                sel_print ("Swapping block ids %i and %i\n",
                           new_bb->index, succ->index);
 
-             i = new_bb->index;
-             new_bb->index = succ->index;
-             succ->index = i;
+             std::swap (new_bb->index, succ->index);
 
              SET_BASIC_BLOCK_FOR_FN (cfun, new_bb->index, new_bb);
              SET_BASIC_BLOCK_FOR_FN (cfun, succ->index, succ);
@@ -4636,15 +4616,13 @@ create_block_for_bookkeeping (edge e1, edge e2)
                      sizeof (rbi));
              memcpy (SEL_REGION_BB_INFO (succ), &rbi, sizeof (rbi));
 
-             i = BLOCK_TO_BB (new_bb->index);
-             BLOCK_TO_BB (new_bb->index) = BLOCK_TO_BB (succ->index);
-             BLOCK_TO_BB (succ->index) = i;
+             std::swap (BLOCK_TO_BB (new_bb->index),
+                        BLOCK_TO_BB (succ->index));
 
-             i = CONTAINING_RGN (new_bb->index);
-             CONTAINING_RGN (new_bb->index) = CONTAINING_RGN (succ->index);
-             CONTAINING_RGN (succ->index) = i;
+             std::swap (CONTAINING_RGN (new_bb->index),
+                        CONTAINING_RGN (succ->index));
 
-             for (i = 0; i < current_nr_blocks; i++)
+             for (int i = 0; i < current_nr_blocks; i++)
                if (BB_TO_BLOCK (i) == succ->index)
                  BB_TO_BLOCK (i) = new_bb->index;
                else if (BB_TO_BLOCK (i) == new_bb->index)
@@ -4669,10 +4647,8 @@ create_block_for_bookkeeping (edge e1, edge e2)
                           CODE_LABEL_NUMBER (BB_HEAD (new_bb)),
                           CODE_LABEL_NUMBER (BB_HEAD (succ)));
 
-             i = CODE_LABEL_NUMBER (BB_HEAD (new_bb));
-             CODE_LABEL_NUMBER (BB_HEAD (new_bb))
-               = CODE_LABEL_NUMBER (BB_HEAD (succ));
-             CODE_LABEL_NUMBER (BB_HEAD (succ)) = i;
+             std::swap (CODE_LABEL_NUMBER (BB_HEAD (new_bb)),
+                        CODE_LABEL_NUMBER (BB_HEAD (succ)));
            }
        }
     }
@@ -4744,11 +4720,10 @@ static int
 find_seqno_for_bookkeeping (insn_t place_to_insert, insn_t join_point)
 {
   int seqno;
-  rtx next;
 
   /* Check if we are about to insert bookkeeping copy before a jump, and use
      jump's seqno for the copy; otherwise, use JOIN_POINT's seqno.  */
-  next = NEXT_INSN (place_to_insert);
+  rtx_insn *next = NEXT_INSN (place_to_insert);
   if (INSN_P (next)
       && JUMP_P (next)
       && BLOCK_FOR_INSN (next) == BLOCK_FOR_INSN (place_to_insert))
@@ -5169,11 +5144,11 @@ find_sequential_best_exprs (bnd_t bnd, expr_t expr_vliw, bool for_moveop)
 static void ATTRIBUTE_UNUSED
 move_nop_to_previous_block (insn_t nop, basic_block prev_bb)
 {
-  insn_t prev_insn, next_insn, note;
+  insn_t prev_insn, next_insn;
 
   gcc_assert (sel_bb_head_p (nop)
               && prev_bb == BLOCK_FOR_INSN (nop)->prev_bb);
-  note = bb_note (BLOCK_FOR_INSN (nop));
+  rtx_note *note = bb_note (BLOCK_FOR_INSN (nop));
   prev_insn = sel_bb_end (prev_bb);
   next_insn = NEXT_INSN (nop);
   gcc_assert (prev_insn != NULL_RTX
@@ -5833,7 +5808,7 @@ move_op_after_merge_succs (cmpd_local_params_p lp, void *sparams)
 /* Track bookkeeping copies created, insns scheduled, and blocks for
    rescheduling when INSN is found by move_op.  */
 static void
-track_scheduled_insns_and_blocks (rtx insn)
+track_scheduled_insns_and_blocks (rtx_insn *insn)
 {
   /* Even if this insn can be a copy that will be removed during current move_op,
      we still need to count it as an originator.  */
@@ -6759,10 +6734,11 @@ static void
 init_seqno_1 (basic_block bb, sbitmap visited_bbs, bitmap blocks_to_reschedule)
 {
   int bbi = BLOCK_TO_BB (bb->index);
-  insn_t insn, note = bb_note (bb);
+  insn_t insn;
   insn_t succ_insn;
   succ_iterator si;
 
+  rtx_note *note = bb_note (bb);
   bitmap_set_bit (visited_bbs, bbi);
   if (blocks_to_reschedule)
     bitmap_clear_bit (blocks_to_reschedule, bb->index);