From patchwork Mon Dec 13 15:25:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 75365 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 757751007D1 for ; Tue, 14 Dec 2010 02:25:22 +1100 (EST) Received: (qmail 13704 invoked by alias); 13 Dec 2010 15:25:20 -0000 Received: (qmail 13689 invoked by uid 22791); 13 Dec 2010 15:25:19 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, FSL_RU_URL, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.ispras.ru (HELO smtp.ispras.ru) (83.149.198.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 15:25:13 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id 6E96D5D40B7; Mon, 13 Dec 2010 18:19:17 +0300 (MSK) Received: from monoid.intra.ispras.ru (unknown [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id 8D3E33FC48; Mon, 13 Dec 2010 18:25:11 +0300 (MSK) Date: Mon, 13 Dec 2010 18:25:11 +0300 (MSK) From: Alexander Monakov To: gcc-patches@gcc.gnu.org cc: "Vladimir N. Makarov" Subject: [PR46875] sel-sched: don't try to remove tablejumps Message-ID: 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 Hi, This fixes a fallout from my previous sel-sched patch (PR45354). I've relaxed jump type checking in bb_has_removable_jump_to_p, and as a result sel-sched would try to remove degenerate tablejumps (if their only destination is the next basic block). However, tidy_fallthru_edge would not mark the edge fallthrough because of the jump table that is left in the insn stream between basic blocks, causing an ICE in verify_flow_info. The patch adjusts the check in bb_has_removable_jump_to_p to not consider tablejumps for deletion. It also adjusts dumping of jump tables in "slim" mode (it currently just prints garbage, the patch changes it to "sequence"). Bootstrapped and regtested on x86_64-linux, OK for trunk? 2010-12-13 Alexander Monakov PR rtl-optimization/46875 * sched-vis.c (print_pattern): Dump "sequence" for ADDR_VECs. * sel-sched-ir.c (bb_has_removable_jump_to_p): Forbid table jumps. testsuite: gcc.dg/pr46875.c: New. diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index 83c423a..d4a5644 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -604,7 +604,7 @@ print_pattern (char *buf, const_rtx x, int verbose) sprintf (buf, "asm {%s}", XSTR (x, 0)); break; case ADDR_VEC: - break; + /* Fall through. */ case ADDR_DIFF_VEC: print_value (buf, XEXP (x, 0), verbose); break; diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c index 2696882..427fd22 100644 --- a/gcc/sel-sched-ir.c +++ b/gcc/sel-sched-ir.c @@ -6109,7 +6109,8 @@ sel_is_loop_preheader_p (basic_block bb) static bool bb_has_removable_jump_to_p (basic_block jump_bb, basic_block dest_bb) { - if (!onlyjump_p (BB_END (jump_bb))) + if (!onlyjump_p (BB_END (jump_bb)) + || tablejump_p (BB_END (jump_bb), NULL, NULL)) return false; /* Several outgoing edges, abnormal edge or destination of jump is diff --git a/gcc/testsuite/gcc.dg/pr46875.c b/gcc/testsuite/gcc.dg/pr46875.c new file mode 100644 index 0000000..c601708 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr46875.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2" } */ + +long +foo (int x, long *y) +{ + long a = 0; + switch (x) + { + case 0: + a = *y; + break; + case 1: + a = *y; + break; + case 2: + a = *y; + break; + case 3: + a = *y; + break; + case 4: + a = *y; + break; + } + return a; +}