OSDN Git Service

PR c++/49165
[pf3gnuchains/gcc-fork.git] / gcc / jump.c
index 6ce989d..1c64b85 100644 (file)
@@ -1,6 +1,6 @@
 /* Optimize jump instructions, for GNU compiler.
    Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997
-   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -47,10 +47,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "insn-attr.h"
 #include "recog.h"
 #include "function.h"
+#include "basic-block.h"
 #include "expr.h"
 #include "except.h"
-#include "diagnostic.h"
-#include "toplev.h"
+#include "diagnostic-core.h"
 #include "reload.h"
 #include "predict.h"
 #include "timevar.h"
@@ -72,12 +72,9 @@ static void redirect_exp_1 (rtx *, rtx, rtx, rtx);
 static int invert_exp_1 (rtx, rtx);
 static int returnjump_p_1 (rtx *, void *);
 \f
-/* This function rebuilds the JUMP_LABEL field and REG_LABEL_TARGET
-   notes in jumping insns and REG_LABEL_OPERAND notes in non-jumping
-   instructions and jumping insns that have labels as operands
-   (e.g. cbranchsi4).  */
-void
-rebuild_jump_labels (rtx f)
+/* Worker for rebuild_jump_labels and rebuild_jump_labels_chain.  */
+static void
+rebuild_jump_labels_1 (rtx f, bool count_forced)
 {
   rtx insn;
 
@@ -89,11 +86,31 @@ rebuild_jump_labels (rtx f)
      closely enough to delete them here, so make sure their reference
      count doesn't drop to zero.  */
 
-  for (insn = forced_labels; insn; insn = XEXP (insn, 1))
-    if (LABEL_P (XEXP (insn, 0)))
-      LABEL_NUSES (XEXP (insn, 0))++;
+  if (count_forced)
+    for (insn = forced_labels; insn; insn = XEXP (insn, 1))
+      if (LABEL_P (XEXP (insn, 0)))
+       LABEL_NUSES (XEXP (insn, 0))++;
   timevar_pop (TV_REBUILD_JUMP);
 }
+
+/* This function rebuilds the JUMP_LABEL field and REG_LABEL_TARGET
+   notes in jumping insns and REG_LABEL_OPERAND notes in non-jumping
+   instructions and jumping insns that have labels as operands
+   (e.g. cbranchsi4).  */
+void
+rebuild_jump_labels (rtx f)
+{
+  rebuild_jump_labels_1 (f, true);
+}
+
+/* This function is like rebuild_jump_labels, but doesn't run over
+   forced_labels.  It can be used on insn chains that aren't the 
+   main function chain.  */
+void
+rebuild_jump_labels_chain (rtx chain)
+{
+  rebuild_jump_labels_1 (chain, false);
+}
 \f
 /* Some old code expects exactly one BARRIER as the NEXT_INSN of a
    non-fallthru insn.  This is not generally true, as multiple barriers
@@ -193,7 +210,7 @@ mark_all_labels (rtx f)
   rtx prev_nonjump_insn = NULL;
 
   for (insn = f; insn; insn = NEXT_INSN (insn))
-    if (INSN_P (insn))
+    if (NONDEBUG_INSN_P (insn))
       {
        mark_jump_label (PATTERN (insn), insn, 0);
 
@@ -308,8 +325,9 @@ reversed_comparison_code_parts (enum rtx_code code, const_rtx arg0,
     {
 #ifdef REVERSE_CONDITION
       return REVERSE_CONDITION (code, mode);
-#endif
+#else
       return reverse_condition (code);
+#endif
     }
 
   /* Try a few special cases based on the comparison code.  */
@@ -1349,7 +1367,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn)
          if (nlabel)
            n = gen_rtx_LABEL_REF (Pmode, nlabel);
          else
-           n = gen_rtx_RETURN (VOIDmode);
+           n = ret_rtx;
 
          validate_change (insn, loc, n, 1);
          return;
@@ -1360,7 +1378,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn)
       if (nlabel)
        x = gen_rtx_LABEL_REF (Pmode, nlabel);
       else
-       x = gen_rtx_RETURN (VOIDmode);
+       x = ret_rtx;
       if (loc == &PATTERN (insn))
        x = gen_rtx_SET (VOIDmode, pc_rtx, x);
       validate_change (insn, loc, x, 1);
@@ -1371,7 +1389,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn)
       && GET_CODE (SET_SRC (x)) == LABEL_REF
       && XEXP (SET_SRC (x), 0) == olabel)
     {
-      validate_change (insn, loc, gen_rtx_RETURN (VOIDmode), 1);
+      validate_change (insn, loc, ret_rtx, 1);
       return;
     }
 
@@ -1727,7 +1745,13 @@ rtx_renumbered_equal_p (const_rtx x, const_rtx y)
 
        case 'i':
          if (XINT (x, i) != XINT (y, i))
-           return 0;
+           {
+             if (((code == ASM_OPERANDS && i == 6)
+                  || (code == ASM_INPUT && i == 1))
+                 && locator_eq (XINT (x, i), XINT (y, i)))
+               break;
+             return 0;
+           }
          break;
 
        case 't':