[4.0/mainline] PR 21562

Jan Hubicka jh@suse.cz
Fri May 27 00:21:00 GMT 2005


Hi,
the attached testcase gets misscompiled with checking disabled compiler
and fails misserably with checking enabled since we manage to insert
basic block before the very first one in the function.

Bootstrapped/regtested i686-pc-gnu-linux with 4.0, mainline and
tree-profiling, OK?
Honza

/* { dg-options "-O3 -fno-inline" } */
struct foo { int a, b, c; };

void
brother (int a, int b, int c)
{
  if (a)
    abort ();
}

void
sister (struct foo f, int b, int c)
{
  brother ((f.b == b), b, c);
}

int
main ()
{
  struct foo f = { 7, 8, 9 };
  sister (f, 1, 2);
  exit (0);
}

2005-05-27  Jan Hubicka  <jh@suse.cz>
	PR tree-optimization/21562
	* cfgexpand.c (construct_init_block): Deal properly with the case
	of entry edge not pointing to very first basic block.
Index: cfgexpand.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgexpand.c,v
retrieving revision 1.1.2.31
diff -c -3 -p -r1.1.2.31 cfgexpand.c
*** cfgexpand.c	21 May 2005 08:46:52 -0000	1.1.2.31
--- cfgexpand.c	24 May 2005 20:22:41 -0000
*************** construct_init_block (void)
*** 1159,1164 ****
--- 1159,1165 ----
    basic_block init_block, first_block;
    edge e = NULL, e2;
    edge_iterator ei;
+   int flags;
  
    FOR_EACH_EDGE (e2, ei, ENTRY_BLOCK_PTR->succs)
      {
*************** construct_init_block (void)
*** 1170,1179 ****
  	 This caused PR17513.  */
        e2->flags &= ~EDGE_EXECUTABLE;
  
!       if (e2->dest == ENTRY_BLOCK_PTR->next_bb)
  	e = e2;
      }
  
    init_block = create_basic_block (NEXT_INSN (get_insns ()),
  				   get_last_insn (),
  				   ENTRY_BLOCK_PTR);
--- 1171,1196 ----
  	 This caused PR17513.  */
        e2->flags &= ~EDGE_EXECUTABLE;
  
!       if (!(e2->flags & EDGE_ABNORMAL))
!       {
! 	/* Multiple entry points not supported yet.  */
! 	gcc_assert (!e);
  	e = e2;
+       }
      }
  
+   /* When entry edge points to first basic block, we don't need jump,
+      otherwise we have to jump into proper target.  */
+   if (e && e->dest != ENTRY_BLOCK_PTR->next_bb)
+     {
+       tree label = tree_block_label (e->dest);
+ 
+       emit_jump (label_rtx (label));
+       flags = 0;
+     }
+   else
+     flags = EDGE_FALLTHRU;
+ 
    init_block = create_basic_block (NEXT_INSN (get_insns ()),
  				   get_last_insn (),
  				   ENTRY_BLOCK_PTR);
*************** construct_init_block (void)
*** 1183,1189 ****
      {
        first_block = e->dest;
        redirect_edge_succ (e, init_block);
!       e = make_edge (init_block, first_block, EDGE_FALLTHRU);
      }
    else
      e = make_edge (init_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
--- 1200,1206 ----
      {
        first_block = e->dest;
        redirect_edge_succ (e, init_block);
!       e = make_edge (init_block, first_block, flags);
      }
    else
      e = make_edge (init_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);



More information about the Gcc-patches mailing list