From patchwork Mon Sep 19 08:49:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Belevantsev X-Patchwork-Id: 115304 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 2610BB6F86 for ; Mon, 19 Sep 2011 18:51:27 +1000 (EST) Received: (qmail 31714 invoked by alias); 19 Sep 2011 08:51:23 -0000 Received: (qmail 31704 invoked by uid 22791); 19 Sep 2011 08:51:21 -0000 X-SWARE-Spam-Status: No, hits=-2.0 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; Mon, 19 Sep 2011 08:51:07 +0000 Received: from [10.10.3.52] (winnie.ispras.ru [83.149.198.236]) by smtp.ispras.ru (Postfix) with ESMTP id EC83F5D4034; Mon, 19 Sep 2011 12:38:52 +0400 (MSD) Message-ID: <4E77020F.90208@ispras.ru> Date: Mon, 19 Sep 2011 12:49:19 +0400 From: Andrey Belevantsev User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 MIME-Version: 1.0 To: GCC Patches CC: "Vladimir N. Makarov" Subject: [PATCH] Fix PR 48374 X-IsSubscribed: yes 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 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 (); + }