From patchwork Tue Oct 25 16:44:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 121749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 20B3DB6F8B for ; Wed, 26 Oct 2011 03:44:45 +1100 (EST) Received: (qmail 19888 invoked by alias); 25 Oct 2011 16:44:40 -0000 Received: (qmail 19877 invoked by uid 22791); 25 Oct 2011 16:44:37 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.202) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Oct 2011 16:44:18 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 521E65D4034; Tue, 25 Oct 2011 20:29:28 +0400 (MSD) Received: from monoid.intra.ispras.ru (winnie.ispras.ru [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id 2CB403FC48; Tue, 25 Oct 2011 20:44:16 +0400 (MSD) Date: Tue, 25 Oct 2011 20:44:16 +0400 (MSD) From: Alexander Monakov To: Andrey Belevantsev cc: GCC Patches , "Vladimir N. Makarov" Subject: Re: [PATCH] Fix PR 48374 In-Reply-To: <4E77020F.90208@ispras.ru> Message-ID: References: <4E77020F.90208@ispras.ru> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * sel-sched-ir.c (bb_has_removable_jump_to_p): Do not allow to make edges leading to the exit block fallthrough. 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 > > 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 (); > + } > +} > > 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. */