This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 48374
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Andrey Belevantsev <abel at ispras dot ru>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, "Vladimir N. Makarov" <vmakarov at redhat dot com>
- Date: Tue, 25 Oct 2011 20:44:16 +0400 (MSD)
- Subject: Re: [PATCH] Fix PR 48374
- References: <4E77020F.90208@ispras.ru>
I'd like to ping Andrey's patch (quoted below).
Additionally, the following patch is needed to fix a different instance where
sel-sched does not expect quirky regions in the vicinity of
__builtin_unreachable.
Both patches were bootstrapped and regtested on x86_64-linux, OK for trunk?
2011-10-25 Alexander Monakov <amonakov@ispras.ru>
* sel-sched-ir.c (bb_has_removable_jump_to_p): Do not allow to make
edges leading to the exit block fallthrough.
diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index dacee0b..a4fb9ac 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -6287,7 +6287,8 @@ bb_has_removable_jump_to_p (basic_block jump_bb, basic_block dest_bb)
not DEST_BB. */
if (EDGE_COUNT (jump_bb->succs) != 1
|| EDGE_SUCC (jump_bb, 0)->flags & (EDGE_ABNORMAL | EDGE_CROSSING)
- || EDGE_SUCC (jump_bb, 0)->dest != dest_bb)
+ || EDGE_SUCC (jump_bb, 0)->dest != dest_bb
+ || dest_bb == EXIT_BLOCK_PTR)
return false;
/* If not anything of the upper. */
On Mon, 19 Sep 2011, Andrey Belevantsev wrote:
> Hello,
>
> The problem here is the case where the selective scheduler doesn't expect
> having a block with zero successors. The patch is near obvious which is why
> it was forgotten for nearly half a year, but still it applies cleanly and
> fixes the testcase, full testing is in progress. OK for trunk and active
> branches if it succeeds?
>
> Yours,
> Andrey
>
> 2011-09-19 Andrey Belevantsev <abel@ispras.ru>
>
> gcc/
> PR rtl-optimization/48374
>
> * sel-sched-ir.h (get_all_loop_exits): Stop iterating when the current
> block has zero successors.
>
> gcc/testsuite
>
> PR rtl-optimization/48374
> * gcc.dg/pr48374.c: New test.
>
> diff --git a/gcc/sel-sched-ir.h b/gcc/sel-sched-ir.h
> index 5516da9..13af1b5 100644
> --- a/gcc/sel-sched-ir.h
> +++ b/gcc/sel-sched-ir.h
> @@ -1119,7 +1119,8 @@ get_all_loop_exits (basic_block bb)
> /* If bb is empty, and we're skipping to loop exits, then
> consider bb as a possible gate to the inner loop now. */
> while (sel_bb_empty_or_nop_p (bb)
> - && in_current_region_p (bb))
> + && in_current_region_p (bb)
> + && EDGE_COUNT (bb->succs) > 0)
> {
> bb = single_succ (bb);
>
> diff --git a/gcc/testsuite/gcc.dg/pr48374.c b/gcc/testsuite/gcc.dg/pr48374.c
> new file mode 100644
> index 0000000..5486cec
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr48374.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */
> +/* { dg-options "-O -fschedule-insns2 -fsel-sched-pipelining
> -fsel-sched-pipelining-outer-loops -fselective-scheduling2 --param
> max-sched-extend-regions-iters=2" } */
> +
> +void foo (int y)
> +{
> + switch (y)
> + {
> + case 3:
> + case 5:
> + case 7:
> + case 11:
> + break;
> + default:
> + __builtin_unreachable ();
> + }
> +}
>
>