OSDN Git Service

PR target/34930
[pf3gnuchains/gcc-fork.git] / gcc / loop-invariant.c
index 3d4ce61..ba1f288 100644 (file)
@@ -5,7 +5,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
+Free Software Foundation; either version 3, or (at your option) any
 later version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT
@@ -14,9 +14,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 /* This implements the loop invariant motion pass.  It is very simple
    (no calls, libcalls, etc.).  This should be sufficient to cleanup things
@@ -186,6 +185,7 @@ check_maybe_invariant (rtx x)
     {
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_FIXED:
     case SYMBOL_REF:
     case CONST:
     case LABEL_REF:
@@ -284,6 +284,7 @@ hash_invariant_expr_1 (rtx insn, rtx x)
     {
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_FIXED:
     case SYMBOL_REF:
     case CONST:
     case LABEL_REF:
@@ -344,6 +345,7 @@ invariant_expr_equal_p (rtx insn1, rtx e1, rtx insn2, rtx e2)
     {
     case CONST_INT:
     case CONST_DOUBLE:
+    case CONST_FIXED:
     case SYMBOL_REF:
     case CONST:
     case LABEL_REF:
@@ -642,6 +644,7 @@ find_defs (struct loop *loop, basic_block *body)
 
   if (dump_file)
     {
+      df_dump_region (dump_file);
       fprintf (dump_file, "*****starting processing of loop  ******\n");
       print_rtl_with_bb (dump_file, get_insns ());
       fprintf (dump_file, "*****ending processing of loop  ******\n");
@@ -1124,7 +1127,7 @@ find_invariants_to_move (void)
 {
   unsigned i, regs_used, regs_needed = 0, new_regs;
   struct invariant *inv = NULL;
-  unsigned int n_regs = DF_REG_SIZE ();
+  unsigned int n_regs = DF_REG_SIZE (df);
 
   if (!VEC_length (invariant_p, invariants))
     return;
@@ -1151,20 +1154,6 @@ find_invariants_to_move (void)
     }
 }
 
-/* Returns true if all insns in SEQ are valid.  */
-
-static bool
-seq_insns_valid_p (rtx seq)
-{
-  rtx x;
-
-  for (x = seq; x; x = NEXT_INSN (x))
-    if (insn_invalid_p (x))
-      return false;
-
-  return true;
-}
-
 /* Move invariant INVNO out of the LOOP.  Returns true if this succeeds, false
    otherwise.  */
 
@@ -1175,7 +1164,7 @@ move_invariant_reg (struct loop *loop, unsigned invno)
   struct invariant *repr = VEC_index (invariant_p, invariants, inv->eqto);
   unsigned i;
   basic_block preheader = loop_preheader_edge (loop)->src;
-  rtx reg, set, dest, seq, op;
+  rtx reg, set, dest, note;
   struct use *use;
   bitmap_iterator bi;
 
@@ -1206,49 +1195,23 @@ move_invariant_reg (struct loop *loop, unsigned invno)
       dest = SET_DEST (set);
       reg = gen_reg_rtx (GET_MODE (dest));
 
-      /* If the SET_DEST of the invariant insn is a pseudo, we can just move
-        the insn out of the loop.  Otherwise, we have to use gen_move_insn
-        to let emit_move_insn produce a valid instruction stream.  */
-      if (REG_P (dest) && !HARD_REGISTER_P (dest))
-       {
-         rtx note;
-
-         emit_insn_after (gen_move_insn (dest, reg), inv->insn);
-         SET_DEST (set) = reg;
-         df_insn_rescan (inv->insn);
-         reorder_insns (inv->insn, inv->insn, BB_END (preheader));
-
-         /* If there is a REG_EQUAL note on the insn we just moved, and
-            insn is in a basic block that is not always executed, the note
-            may no longer be valid after we move the insn.
-            Note that uses in REG_EQUAL notes are taken into account in
-            the computation of invariants.  Hence it is safe to retain the
-            note even if the note contains register references.  */
-         if (! inv->always_executed
-             && (note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX)))
-           remove_note (inv->insn, note);
-       }
-      else
-       {
-         start_sequence ();
-         op = force_operand (SET_SRC (set), reg);
-         if (!op)
-           {
-             end_sequence ();
-             goto fail;
-           }
-         if (op != reg)
-           emit_move_insn (reg, op);
-         seq = get_insns ();
-         end_sequence ();
-
-         if (!seq_insns_valid_p (seq))
-           goto fail;
-         emit_insn_after (seq, BB_END (preheader));
-      
-         emit_insn_after (gen_move_insn (dest, reg), inv->insn);
-         delete_insn (inv->insn);
-       }
+      /* Try replacing the destination by a new pseudoregister.  */
+      if (!validate_change (inv->insn, &SET_DEST (set), reg, false))
+       goto fail;
+      df_insn_rescan (inv->insn);
+
+      emit_insn_after (gen_move_insn (dest, reg), inv->insn);
+      reorder_insns (inv->insn, inv->insn, BB_END (preheader));
+
+      /* If there is a REG_EQUAL note on the insn we just moved, and
+        insn is in a basic block that is not always executed, the note
+        may no longer be valid after we move the insn.
+        Note that uses in REG_EQUAL notes are taken into account in
+        the computation of invariants.  Hence it is safe to retain the
+        note even if the note contains register references.  */
+      if (! inv->always_executed
+         && (note = find_reg_note (inv->insn, REG_EQUAL, NULL_RTX)))
+       remove_note (inv->insn, note);
     }
   else
     {