[patch] jump.c: avoid clobbers when combining jumps
DJ Delorie
dj@redhat.com
Wed Feb 14 10:34:00 GMT 2001
Pre-approved by rth, and committed by me. Fixes
gcc.c-torture/execute/20001130-2.c (for sparc targets, at least) with
no regressions on sparc or x86. Let me know if it should go in 3.0
also.
2001-02-14 Richard Henderson <rth@redhat.com>
DJ Delorie <dj@redhat.com>
* jump.c (jump_optimize_1): When we delete a conditional jump
preceeding a non-conditional jump to effectively the same place,
make sure that the combined jump skips any clobber insns between
the two labels.
Index: jump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/jump.c,v
retrieving revision 1.153
diff -p -2 -r1.153 jump.c
*** jump.c 2001/02/11 06:19:29 1.153
--- jump.c 2001/02/14 18:31:30
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 421,424 ****
--- 421,446 ----
if (temp2 == temp)
{
+ /* Ensure that we jump to the later of the two labels.
+ Consider:
+
+ if (test) goto L2;
+ goto L1;
+ ...
+ L1:
+ (clobber return-reg)
+ L2:
+ (use return-reg)
+
+ If we leave the goto L1, we'll incorrectly leave
+ return-reg dead for TEST true. */
+
+ temp2 = next_active_insn (JUMP_LABEL (insn));
+ if (!temp2)
+ temp2 = get_last_insn ();
+ if (GET_CODE (temp2) != CODE_LABEL)
+ temp2 = prev_label (temp2);
+ if (temp2 != JUMP_LABEL (temp))
+ redirect_jump (temp, temp2, 1);
+
delete_jump (insn);
changed = 1;
More information about the Gcc-patches
mailing list