Skip to content

Commit

Permalink
re PR rtl-optimization/32773 (SH: ICE in create_pre_exit, at mode-swi…
Browse files Browse the repository at this point in the history
…tching.c:223)

	PR rtl-optimization/32773
	* cfglayout.c (force_one_exit_fallthru): New function.
	(cfg_layout_finalize): Use it.

	* gcc.dg/pr32773.c: New test.

From-SVN: r126700
  • Loading branch information
Zdenek Dvorak authored and Zdenek Dvorak committed Jul 17, 2007
1 parent 02634bb commit 9f2e9ac
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2007-07-17 Zdenek Dvorak <[email protected]>

PR rtl-optimization/32773
* cfglayout.c (force_one_exit_fallthru): New function.
(cfg_layout_finalize): Use it.

2007-07-16 Richard Guenther <[email protected]>
Uros Bizjak <[email protected]>

Expand Down
51 changes: 51 additions & 0 deletions gcc/cfglayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,56 @@ fixup_fallthru_exit_predecessor (void)
bb->aux = NULL;
}
}

/* In case there are more than one fallthru predecessors of exit, force that
there is only one. */

static void
force_one_exit_fallthru (void)
{
edge e, predecessor = NULL;
bool more = false;
edge_iterator ei;
basic_block forwarder, bb;

FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
if (e->flags & EDGE_FALLTHRU)
{
if (predecessor == NULL)
predecessor = e;
else
{
more = true;
break;
}
}

if (!more)
return;

/* Exit has several fallthru predecessors. Create a forwarder block for
them. */
forwarder = split_edge (predecessor);
for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
{
if (e->src == forwarder
|| !(e->flags & EDGE_FALLTHRU))
ei_next (&ei);
else
redirect_edge_and_branch_force (e, forwarder);
}

/* Fix up the chain of blocks -- make FORWARDER immediately preceed the
exit block. */
FOR_EACH_BB (bb)
{
if (bb->aux == NULL && bb != forwarder)
{
bb->aux = forwarder;
break;
}
}
}

/* Return true in case it is possible to duplicate the basic block BB. */

Expand Down Expand Up @@ -1178,6 +1228,7 @@ cfg_layout_finalize (void)
#ifdef ENABLE_CHECKING
verify_flow_info ();
#endif
force_one_exit_fallthru ();
rtl_register_cfg_hooks ();
if (reload_completed
#ifdef HAVE_epilogue
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2007-07-17 Zdenek Dvorak <[email protected]>

PR rtl-optimization/32773
* gcc.dg/pr32773.c: New test.

2007-07-16 Andrew Pinski <[email protected]>

* gcc.target/spu/intrinsics-1.c: Use dg-message to
Expand Down
11 changes: 11 additions & 0 deletions gcc/testsuite/gcc.dg/pr32773.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* { dg-do compile } */
/* { dg-options "-O -fprofile-use" } */
/* { dg-options "-O -m4 -fprofile-use" { target sh-*-* } } */

void foo (int *p)
{
if (p)
*p = 0;
} /* { dg-message "note: \[^\n\]*execution counts estimated" } */

/* { dg-final { cleanup-coverage-files } } */

0 comments on commit 9f2e9ac

Please sign in to comment.