From patchwork Thu Apr 7 17:16:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 90213 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 316B91007D1 for ; Fri, 8 Apr 2011 03:16:23 +1000 (EST) Received: (qmail 15010 invoked by alias); 7 Apr 2011 17:16:18 -0000 Received: (qmail 14997 invoked by uid 22791); 7 Apr 2011 17:16:15 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_JMF_BL, TW_QN, T_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; Thu, 07 Apr 2011 17:16:10 +0000 Received: from ispserv.ispras.ru (ispserv.ispras.ru [83.149.198.72]) by smtp.ispras.ru (Postfix) with ESMTP id CC0795D4045; Thu, 7 Apr 2011 21:15:39 +0400 (MSD) Received: from monoid.intra.ispras.ru (winnie.ispras.ru [83.149.198.236]) by ispserv.ispras.ru (Postfix) with ESMTP id CC1C43FC48; Thu, 7 Apr 2011 21:16:08 +0400 (MSD) Date: Thu, 7 Apr 2011 21:16:08 +0400 (MSD) From: Alexander Monakov To: gcc-patches@gcc.gnu.org cc: "Vladimir N. Makarov" Subject: [PATCH] sel-sched: Fix an incorrect assert (PR 48442) 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 patch fixes an incorrect assert in init_seqno and cleans up adjacent code a bit by removing an unneeded argument. Bootstrapped and regtested together with other recent sel-sched fixes on x86_64-linux with scheduler enabled at -O2. OK for trunk? PR rtl-optimization/48442 * sel-sched.c (init_seqno): Remove number_of_insns argument. Update all callers. Adjust assert. testsuite: * gcc.dg/pr48442.c: New. diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index 9179249..0e8173b 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -6731,15 +6731,14 @@ init_seqno_1 (basic_block bb, sbitmap visited_bbs, bitmap blocks_to_reschedule) INSN_SEQNO (insn) = cur_seqno--; } -/* Initialize seqnos for the current region. NUMBER_OF_INSNS is the number - of instructions in the region, BLOCKS_TO_RESCHEDULE contains blocks on - which we're rescheduling when pipelining, FROM is the block where +/* Initialize seqnos for the current region. BLOCKS_TO_RESCHEDULE contains + blocks on which we're rescheduling when pipelining, FROM is the block where traversing region begins (it may not be the head of the region when pipelining, but the head of the loop instead). Returns the maximal seqno found. */ static int -init_seqno (int number_of_insns, bitmap blocks_to_reschedule, basic_block from) +init_seqno (bitmap blocks_to_reschedule, basic_block from) { sbitmap visited_bbs; bitmap_iterator bi; @@ -6762,9 +6761,13 @@ init_seqno (int number_of_insns, bitmap blocks_to_reschedule, basic_block from) from = EBB_FIRST_BB (0); } - cur_seqno = number_of_insns > 0 ? number_of_insns : sched_max_luid - 1; + cur_seqno = sched_max_luid - 1; init_seqno_1 (from, visited_bbs, blocks_to_reschedule); - gcc_assert (cur_seqno == 0 || number_of_insns == 0); + + /* cur_seqno may be positive if the number of instructions is less than + sched_max_luid - 1 (when rescheduling or if some instructions have been + removed by the call to purge_empty_blocks in sel_sched_region_1). */ + gcc_assert (cur_seqno >= 0); sbitmap_free (visited_bbs); return sched_max_luid - 1; @@ -7473,17 +7476,12 @@ sel_sched_region_2 (int orig_max_seqno) static void sel_sched_region_1 (void) { - int number_of_insns; int orig_max_seqno; - /* Remove empty blocks that might be in the region from the beginning. - We need to do save sched_max_luid before that, as it actually shows - the number of insns in the region, and purge_empty_blocks can - alter it. */ - number_of_insns = sched_max_luid - 1; + /* Remove empty blocks that might be in the region from the beginning. */ purge_empty_blocks (); - orig_max_seqno = init_seqno (number_of_insns, NULL, NULL); + orig_max_seqno = init_seqno (NULL, NULL); gcc_assert (orig_max_seqno >= 1); /* When pipelining outer loops, create fences on the loop header, @@ -7560,7 +7558,7 @@ sel_sched_region_1 (void) { flist_tail_init (new_fences); - orig_max_seqno = init_seqno (0, blocks_to_reschedule, bb); + orig_max_seqno = init_seqno (blocks_to_reschedule, bb); /* Mark BB as head of the new ebb. */ bitmap_set_bit (forced_ebb_heads, bb->index); diff --git a/gcc/testsuite/gcc.dg/pr48442.c b/gcc/testsuite/gcc.dg/pr48442.c new file mode 100644 index 0000000..88e3497 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr48442.c @@ -0,0 +1,27 @@ +/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */ +/* { dg-options "-Os -fselective-scheduling2 --param max-sched-extend-regions-iters=100" } */ +void f (void) +{ + unsigned *a2; + int vertex2; + int c, x2, dx2, dy2, s2; + long m, b; + do + { + if (dx2) + dx2 = dx2 % dy2; + s2 = (dx2 / dy2); + } + while (vertex2); + for (;;) + { + c = x2; + a2 = 0; + if (c) + { + m = b << (c); + *a2 = (*a2 & ~m); + } + x2 += s2; + } +}