This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: tetex mis-compilation fix
- To: Jeffrey A Law <law at cygnus dot com>
- Subject: Re: tetex mis-compilation fix
- From: Richard Henderson <rth at cygnus dot com>
- Date: Wed, 4 Aug 1999 13:02:46 -0700
- Cc: gcc-patches at egcs dot cygnus dot com
- References: <8902.933750791@upchuck.cygnus.com>
On Wed, Aug 04, 1999 at 01:13:11AM -0600, Jeffrey A Law wrote:
> The fix (of course) is to not delete a jump that potentially has other
> side effects.
>
> * flow.c (delete_unreachable_blocks): Do not call merge_blocks
> or tidy_fallthru_edge if the last insn in the block is not
> an unconditional jump or a simple conditional jump.
Consider this alternative patch.
r~
* jump.c (onlyjump_p): New function.
* rtl.h: Declare it.
* flow.c (delete_unreachable_blocks): Use onlyjump_p instead
of condjump_p in calling tidy_fallthru_edge and merge_blocks.
Index: jump.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/jump.c,v
retrieving revision 1.63
diff -c -p -d -r1.63 jump.c
*** jump.c 1999/08/04 08:19:36 1.63
--- jump.c 1999/08/04 19:58:03
*************** returnjump_p (insn)
*** 3528,3533 ****
--- 3528,3556 ----
return for_each_rtx (&PATTERN (insn), returnjump_p_1, NULL);
}
+ /* Return true if INSN is a jump that only transfers control and
+ nothing more. */
+
+ int
+ onlyjump_p (insn)
+ rtx insn;
+ {
+ rtx set;
+
+ if (GET_CODE (insn) != JUMP_INSN)
+ return 0;
+
+ set = single_set (insn);
+ if (set == NULL)
+ return 0;
+ if (GET_CODE (SET_DEST (set)) != PC)
+ return 0;
+ if (side_effects_p (SET_SRC (set)))
+ return 0;
+
+ return 1;
+ }
+
#ifdef HAVE_cc0
/* Return 1 if X is an RTX that does nothing but set the condition codes
Index: rtl.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/rtl.h,v
retrieving revision 1.107
diff -c -p -d -r1.107 rtl.h
*** rtl.h 1999/08/01 12:07:35 1.107
--- rtl.h 1999/08/04 19:58:03
*************** extern int condjump_p PROTO ((rtx));
*** 1352,1357 ****
--- 1352,1358 ----
extern rtx condjump_label PROTO ((rtx));
extern int simplejump_p PROTO ((rtx));
extern int returnjump_p PROTO ((rtx));
+ extern int onlyjump_p PROTO ((rtx));
extern int sets_cc0_p PROTO ((rtx));
extern int invert_jump PROTO ((rtx, rtx));
extern int rtx_renumbered_equal_p PROTO ((rtx, rtx));
Index: flow.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/flow.c,v
retrieving revision 1.127
diff -c -p -d -r1.127 flow.c
*** flow.c 1999/08/04 07:11:26 1.127
--- flow.c 1999/08/04 19:58:03
*************** delete_unreachable_blocks ()
*** 1564,1574 ****
if ((s = b->succ) != NULL
&& s->succ_next == NULL
&& s->dest == c
! /* If the last insn is not a normal conditional jump
! (or an unconditional jump), then we can not tidy the
! fallthru edge because we can not delete the jump. */
! && GET_CODE (b->end) == JUMP_INSN
! && condjump_p (b->end))
tidy_fallthru_edge (s, b, c);
}
--- 1564,1572 ----
if ((s = b->succ) != NULL
&& s->succ_next == NULL
&& s->dest == c
! /* If the jump insn has side effects, we can't tidy the edge. */
! && (GET_CODE (b->end) != JUMP_INSN
! || onlyjump_p (b->end)))
tidy_fallthru_edge (s, b, c);
}
*************** delete_unreachable_blocks ()
*** 1587,1597 ****
&& (s->flags & EDGE_EH) == 0
&& (c = s->dest) != EXIT_BLOCK_PTR
&& c->pred->pred_next == NULL
! /* If the last insn is not a normal conditional jump
! (or an unconditional jump), then we can not merge
! the blocks because we can not delete the jump. */
! && GET_CODE (b->end) == JUMP_INSN
! && condjump_p (b->end)
&& merge_blocks (s, b, c))
continue;
--- 1585,1593 ----
&& (s->flags & EDGE_EH) == 0
&& (c = s->dest) != EXIT_BLOCK_PTR
&& c->pred->pred_next == NULL
! /* If the jump insn has side effects, we can't kill the edge. */
! && (GET_CODE (b->end) != JUMP_INSN
! || onlyjump_p (b->end))
&& merge_blocks (s, b, c))
continue;