Skip to content

Commit 9f2e9ac

Browse files
Zdenek DvorakZdenek Dvorak
authored andcommitted
re PR rtl-optimization/32773 (SH: ICE in create_pre_exit, at mode-switching.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
1 parent 02634bb commit 9f2e9ac

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

gcc/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2007-07-17 Zdenek Dvorak <dvorakz@suse.cz>
2+
3+
PR rtl-optimization/32773
4+
* cfglayout.c (force_one_exit_fallthru): New function.
5+
(cfg_layout_finalize): Use it.
6+
17
2007-07-16 Richard Guenther <rguenther@suse.de>
28
Uros Bizjak <ubizjak@gmail.com>
39

gcc/cfglayout.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,56 @@ fixup_fallthru_exit_predecessor (void)
963963
bb->aux = NULL;
964964
}
965965
}
966+
967+
/* In case there are more than one fallthru predecessors of exit, force that
968+
there is only one. */
969+
970+
static void
971+
force_one_exit_fallthru (void)
972+
{
973+
edge e, predecessor = NULL;
974+
bool more = false;
975+
edge_iterator ei;
976+
basic_block forwarder, bb;
977+
978+
FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
979+
if (e->flags & EDGE_FALLTHRU)
980+
{
981+
if (predecessor == NULL)
982+
predecessor = e;
983+
else
984+
{
985+
more = true;
986+
break;
987+
}
988+
}
989+
990+
if (!more)
991+
return;
992+
993+
/* Exit has several fallthru predecessors. Create a forwarder block for
994+
them. */
995+
forwarder = split_edge (predecessor);
996+
for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
997+
{
998+
if (e->src == forwarder
999+
|| !(e->flags & EDGE_FALLTHRU))
1000+
ei_next (&ei);
1001+
else
1002+
redirect_edge_and_branch_force (e, forwarder);
1003+
}
1004+
1005+
/* Fix up the chain of blocks -- make FORWARDER immediately preceed the
1006+
exit block. */
1007+
FOR_EACH_BB (bb)
1008+
{
1009+
if (bb->aux == NULL && bb != forwarder)
1010+
{
1011+
bb->aux = forwarder;
1012+
break;
1013+
}
1014+
}
1015+
}
9661016

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

@@ -1178,6 +1228,7 @@ cfg_layout_finalize (void)
11781228
#ifdef ENABLE_CHECKING
11791229
verify_flow_info ();
11801230
#endif
1231+
force_one_exit_fallthru ();
11811232
rtl_register_cfg_hooks ();
11821233
if (reload_completed
11831234
#ifdef HAVE_epilogue

gcc/testsuite/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2007-07-17 Zdenek Dvorak <dvorakz@suse.cz>
2+
3+
PR rtl-optimization/32773
4+
* gcc.dg/pr32773.c: New test.
5+
16
2007-07-16 Andrew Pinski <andrew_pinski@playstation.sony.com>
27

38
* gcc.target/spu/intrinsics-1.c: Use dg-message to

gcc/testsuite/gcc.dg/pr32773.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* { dg-do compile } */
2+
/* { dg-options "-O -fprofile-use" } */
3+
/* { dg-options "-O -m4 -fprofile-use" { target sh-*-* } } */
4+
5+
void foo (int *p)
6+
{
7+
if (p)
8+
*p = 0;
9+
} /* { dg-message "note: \[^\n\]*execution counts estimated" } */
10+
11+
/* { dg-final { cleanup-coverage-files } } */

0 commit comments

Comments
 (0)