Patchwork Don't update_cfg_for_uncondjump for noop non-jump moves

login
register
mail settings
Submitter Jakub Jelinek
Date April 12, 2011, 5:08 p.m.
Message ID <20110412170826.GG17079@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/90836/
State New
Headers show

Comments

Jakub Jelinek - April 12, 2011, 5:08 p.m.
On Tue, Apr 12, 2011 at 09:18:01AM +0200, Eric Botcazou wrote:
> > The propagate_for_debug change alone could fix it, we should never
> > fall through into next basic block.  We are unforuntately not deleting
> > just jumps (which ought to appear at the end of bbs), but also
> > any other noop moves, which I think is unintentional, we have
> > delete_noop_moves that should clean that up instead (see the second patch).
> 
> Yes, I wondered several times about that.  This clearly looks unintentional and 
> I agree that it is worth fixing on the mainline, adding gcc_assert (at_end); to 
> update_cfg_for_uncondjump in the process.

Here is a patch, bootstrapped/regtested on x86_64-linux and i686-linux.
Ok for trunk?

2011-04-12  Jakub Jelinek  <jakub@redhat.com>

	* combine.c (update_cfg_for_uncondjump): Instead of testing at_end
	assert it is always true.
	(try_combine): Don't call update_cfg_for_uncondjump for noop non-jump
	moves.



	Jakub
Jeff Law - April 12, 2011, 5:11 p.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/12/11 11:08, Jakub Jelinek wrote:
> On Tue, Apr 12, 2011 at 09:18:01AM +0200, Eric Botcazou wrote:
>>> The propagate_for_debug change alone could fix it, we should never
>>> fall through into next basic block.  We are unforuntately not deleting
>>> just jumps (which ought to appear at the end of bbs), but also
>>> any other noop moves, which I think is unintentional, we have
>>> delete_noop_moves that should clean that up instead (see the second patch).
>>
>> Yes, I wondered several times about that.  This clearly looks unintentional and 
>> I agree that it is worth fixing on the mainline, adding gcc_assert (at_end); to 
>> update_cfg_for_uncondjump in the process.
> 
> Here is a patch, bootstrapped/regtested on x86_64-linux and i686-linux.
> Ok for trunk?
> 
> 2011-04-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* combine.c (update_cfg_for_uncondjump): Instead of testing at_end
> 	assert it is always true.
> 	(try_combine): Don't call update_cfg_for_uncondjump for noop non-jump
> 	moves.
Looks good to me, but please wait for Eric to chime in since you've been
discussing it with him already.

Thanks,
jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNpIfYAAoJEBRtltQi2kC7yS4IAJZKDfF2fSkrEV1bWlz2p6Gm
P9w4mby36+tqY6AJBLXlaSo97DCGfhgJHuYNJdtC8a4ySz8EpVmEFdjGAfydU6oc
eIhaKfffm/dC8ciQfIQjBGh3mCe85LAOva9hY/3swyDJ2vFVZud/xY8QcC8RZIOk
b6qZ/whcbTDOWSbII81auzhI9fIfESx5Rk73nD2hUqoi8e5uCMPRlnwsLTDwiJfR
Cv8IJZ1kkIIc0i++wlZ9uuha+oRADcsj6awOKR9F07Qfa/ePU3xWw4e+auA6pfLL
eui0+Xp5BmkwOBc4vF7dl/lxugwRvKXdEB2OdiB96d7dwDBnC6B0a/7zqXZ9bsc=
=bwhq
-----END PGP SIGNATURE-----
Eric Botcazou - April 12, 2011, 5:25 p.m.
> Looks good to me, but please wait for Eric to chime in since you've been
> discussing it with him already.

Fine with me as well.

Patch

--- gcc/combine.c.jj	2011-04-12 12:52:11.963669819 +0200
+++ gcc/combine.c	2011-04-12 16:31:57.059671430 +0200
@@ -2490,13 +2490,12 @@  static void
 update_cfg_for_uncondjump (rtx insn)
 {
   basic_block bb = BLOCK_FOR_INSN (insn);
-  bool at_end = (BB_END (bb) == insn);
+  gcc_assert (BB_END (bb) == insn);
 
-  if (at_end)
-    purge_dead_edges (bb);
+  purge_dead_edges (bb);
 
   delete_insn (insn);
-  if (at_end && EDGE_COUNT (bb->succs) == 1)
+  if (EDGE_COUNT (bb->succs) == 1)
     {
       rtx insn;
 
@@ -4409,7 +4408,8 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx
 
   /* A noop might also need cleaning up of CFG, if it comes from the
      simplification of a jump.  */
-  if (GET_CODE (newpat) == SET
+  if (JUMP_P (i3)
+      && GET_CODE (newpat) == SET
       && SET_SRC (newpat) == pc_rtx
       && SET_DEST (newpat) == pc_rtx)
     {
@@ -4418,6 +4418,7 @@  try_combine (rtx i3, rtx i2, rtx i1, rtx
     }
 
   if (undobuf.other_insn != NULL_RTX
+      && JUMP_P (undobuf.other_insn)
       && GET_CODE (PATTERN (undobuf.other_insn)) == SET
       && SET_SRC (PATTERN (undobuf.other_insn)) == pc_rtx
       && SET_DEST (PATTERN (undobuf.other_insn)) == pc_rtx)