This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
get emit_cmp_and_jump_insn_1 to mark the jump's label
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 22 Jul 2003 02:25:54 -0300
- Subject: get emit_cmp_and_jump_insn_1 to mark the jump's label
- Organization: GCC Team, Red Hat
I ran into an interesting failure on this port I'm working on. Loop
strength reduction decided to emit a mult_add, but the add was in a
wider mode than the machine supported directly, and had to be
synthesized. It turned out that the carry of the lower-word addition
could only be obtained with branch-around-set, so we emitted a branch
without a JUMP_LABEL after the jump pass added those that were
missing, and we ended up crashing while constructing the flow graph.
This patch arranges for the jump instructions emitted by
emit_cmp_and_jump_insn_1 to have the JUMP_LABEL set in them. It is
enough to fix the failure I was observing, but there might be other
situations in which we emit branches without setting their
JUMP_LABELs.
RTH and I agree that, ideally, we shouldn't need the jump pass to add
JUMP_LABELs that are missing, but it's not clear that this is anywhere
nearly feasible with a reasonable effort at the moment, so I'd like to
add this a stop gap.
What we don't agree is that this approach is ideal. RTH seems to be
of the opinion that something along the lines of mark_jump_to_label
should scan a sequence of instructions that might have been passed to
emit_jump_insn, instead of simple-mindedly adding the JUMP_LABEL note
to the insn returned by emit_jump_insn, and only if it turns out to be
a JUMP_INSN. My reasoning is that, if emit_jump_insn() takes a
sequence, the insns in the sequence must have been emitted before,
and, therefore, they should have already been emitted with
JUMP_LABELs, so scanning the seq would not only be inefficient, but
also hide latent bugs.
Anyone else willing to help me convince RTH? :-)
This patch was bootstrapped on i686-pc-linux-gnu, and tested on this
port I'm working on. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* jump.c (mark_jump_to_label): New.
* rtl.h (mark_jump_to_label): Declare it.
* optabs.c (emit_cmp_and_jump_insn_1): Call it.
Index: gcc/jump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/jump.c,v
retrieving revision 1.235
diff -u -p -r1.235 jump.c
--- gcc/jump.c 19 Jul 2003 14:47:07 -0000 1.235
+++ gcc/jump.c 22 Jul 2003 04:18:23 -0000
@@ -1345,6 +1345,16 @@ follow_jumps (rtx label)
}
+/* If the given INSN is a JUMP_INSN, mark it as jumping to the givne LABEL. */
+rtx
+mark_jump_to_label (rtx insn, rtx label)
+{
+ if (GET_CODE (insn) == JUMP_INSN)
+ JUMP_LABEL (insn) = label;
+
+ return insn;
+}
+
/* Find all CODE_LABELs referred to in X, and increment their use counts.
If INSN is a JUMP_INSN and there is at least one CODE_LABEL referenced
in INSN, then store one of them in JUMP_LABEL (INSN).
Index: gcc/rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.430
diff -u -p -r1.430 rtl.h
--- gcc/rtl.h 14 Jul 2003 21:18:14 -0000 1.430
+++ gcc/rtl.h 22 Jul 2003 04:18:25 -0000
@@ -1554,6 +1554,7 @@ extern enum rtx_code reverse_condition_m
extern enum rtx_code swap_condition (enum rtx_code);
extern enum rtx_code unsigned_condition (enum rtx_code);
extern enum rtx_code signed_condition (enum rtx_code);
+extern rtx mark_jump_to_label (rtx, rtx);
extern void mark_jump_label (rtx, rtx, int);
extern void cleanup_barriers (void);
Index: gcc/optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.187
diff -u -p -r1.187 optabs.c
--- gcc/optabs.c 22 Jul 2003 00:36:52 -0000 1.187
+++ gcc/optabs.c 22 Jul 2003 04:18:27 -0000
@@ -3762,7 +3762,9 @@ emit_cmp_and_jump_insn_1 (rtx x, rtx y,
{
x = prepare_operand (icode, x, 1, mode, wider_mode, unsignedp);
y = prepare_operand (icode, y, 2, mode, wider_mode, unsignedp);
- emit_jump_insn (GEN_FCN (icode) (test, x, y, label));
+ mark_jump_to_label
+ (emit_jump_insn (GEN_FCN (icode) (test, x, y, label)),
+ label);
return;
}
}
@@ -3774,7 +3776,9 @@ emit_cmp_and_jump_insn_1 (rtx x, rtx y,
x = prepare_operand (icode, x, 0, mode, wider_mode, unsignedp);
emit_insn (GEN_FCN (icode) (x));
if (label)
- emit_jump_insn ((*bcc_gen_fctn[(int) comparison]) (label));
+ mark_jump_to_label
+ (emit_jump_insn ((*bcc_gen_fctn[(int) comparison]) (label)),
+ label);
return;
}
@@ -3787,7 +3791,9 @@ emit_cmp_and_jump_insn_1 (rtx x, rtx y,
y = prepare_operand (icode, y, 1, mode, wider_mode, unsignedp);
emit_insn (GEN_FCN (icode) (x, y));
if (label)
- emit_jump_insn ((*bcc_gen_fctn[(int) comparison]) (label));
+ mark_jump_to_label
+ (emit_jump_insn ((*bcc_gen_fctn[(int) comparison]) (label)),
+ label);
return;
}
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer