This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] problems with bb-reorder.c rewrite


Hello,

After the recent bb-reorder.c rewrite I had problems on the c4x target.
The problem was that bb-reorder moved a return insn in the code
and did not update the JUMP_LABEL of this insn. I fixed this by
calling rebuild_jump_labels at the end of the bb-reorder pass.
The code that failed is (part of dbra-1.c):

f2 (a)
     long a;
{
  int i;
  for (i = 0; i < 10; i++)
    {
      if (--a != -1)
        return i;
    }
  return -1;
}

The correct assembly code is:

_f2:
        ldiu    ar2,r1
        ldiu    0,r2
        addi    -1,r1
        cmpi    -1,r1	<-deleted
        ldiu    r2,r0
        retsne		<-deleted
...

If the rebuild_jump_labels is not called reorg will delete the
marked insns. The patch to fix this is below.

	Herman.


2003-02-18 Herman A.J. ten Brugge <hermantenbrugge@home.nl>

	* toplev.c (rest_of_compilation): Call rebuild_jump_labels
	after reordering basic blocks.


--- toplev.c.org	2003-02-18 22:05:34.000000000 +0100
+++ toplev.c	2003-02-18 22:11:03.000000000 +0100
@@ -3564,6 +3564,7 @@ rest_of_compilation (decl)
       if (flag_reorder_blocks)
 	{
 	  reorder_basic_blocks ();
+	  rebuild_jump_labels (insns);
 	  cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
 	}
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]