/* 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.
#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"
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;
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
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);
{
#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. */
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;
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);
&& 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;
}
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':