From patchwork Fri Apr 29 05:14:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 93377 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 D4C63B6F76 for ; Fri, 29 Apr 2011 15:15:22 +1000 (EST) Received: (qmail 31966 invoked by alias); 29 Apr 2011 05:15:18 -0000 Received: (qmail 31952 invoked by uid 22791); 29 Apr 2011 05:15:16 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_DB, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Apr 2011 05:14:42 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3T5EXbf011659 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Apr 2011 01:14:33 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3T5EUcg025895 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Apr 2011 01:14:32 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id p3T5ETn4007382; Fri, 29 Apr 2011 02:14:29 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p3T5ESfa023255; Fri, 29 Apr 2011 02:14:28 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p3T5EQG6023253; Fri, 29 Apr 2011 02:14:26 -0300 From: Alexandre Oliva To: Bernd Schmidt Cc: "H.J. Lu" , GCC Patches Subject: Re: Scheduler cleanups, 1/N References: <4D8B421E.8090002@codesourcery.com> <4D99DEC7.80104@codesourcery.com> <4D9B84D8.3090505@codesourcery.com> Date: Fri, 29 Apr 2011 02:14:26 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 05 Apr 2011 19:37:05 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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 On Apr 5, 2011, Alexandre Oliva wrote: >> + if (flag_sched_last_insn_heuristic >> + && NONDEBUG_INSN_P (last_nondebug_scheduled_insn)) >> Isn't that always true now > Not if it's the initial NOTE. >> (except we should probably initialize it to NULL_RTX and check for >> that here)? > Good idea. Will try that, retest, and apply if it passes. Here's what I'm (finally) installing, regstrapped several times on x86_64-linux-gnu and i686-pc-linux-gnu. for gcc/ChangeLog from Alexandre Oliva * haifa-sched.c (last_nondebug_scheduled_insn): New. (rank_for_schedule): Use it. (schedule_block): Set it. Index: gcc/haifa-sched.c =================================================================== --- gcc/haifa-sched.c.orig 2011-04-05 05:29:27.910000535 -0300 +++ gcc/haifa-sched.c 2011-04-05 19:37:59.224096719 -0300 @@ -783,6 +783,12 @@ print_curr_reg_pressure (void) /* Pointer to the last instruction scheduled. */ static rtx last_scheduled_insn; +/* Pointer to the last nondebug instruction scheduled within the + block, or the prev_head of the scheduling block. Used by + rank_for_schedule, so that insns independent of the last scheduled + insn will be preferred over dependent instructions. */ +static rtx last_nondebug_scheduled_insn; + /* Pointer that iterates through the list of unscheduled insns if we have a dbg_cnt enabled. It always points at an insn prior to the first unscheduled one. */ @@ -1158,7 +1164,6 @@ rank_for_schedule (const void *x, const { rtx tmp = *(const rtx *) y; rtx tmp2 = *(const rtx *) x; - rtx last; int tmp_class, tmp2_class; int val, priority_val, info_val; @@ -1239,24 +1244,13 @@ rank_for_schedule (const void *x, const if(flag_sched_rank_heuristic && info_val) return info_val; - if (flag_sched_last_insn_heuristic) - { - int i = VEC_length (rtx, scheduled_insns); - last = NULL_RTX; - while (i-- > 0) - { - last = VEC_index (rtx, scheduled_insns, i); - if (NONDEBUG_INSN_P (last)) - break; - } - } - /* Compare insns based on their relation to the last scheduled non-debug insn. */ - if (flag_sched_last_insn_heuristic && last && NONDEBUG_INSN_P (last)) + if (flag_sched_last_insn_heuristic && last_nondebug_scheduled_insn) { dep_t dep1; dep_t dep2; + rtx last = last_nondebug_scheduled_insn; /* Classify the instructions into three classes: 1) Data dependent on last schedule insn. @@ -2967,6 +2961,7 @@ schedule_block (basic_block *target_bb) /* We start inserting insns after PREV_HEAD. */ last_scheduled_insn = nonscheduled_insns_begin = prev_head; + last_nondebug_scheduled_insn = NULL_RTX; gcc_assert ((NOTE_P (last_scheduled_insn) || DEBUG_INSN_P (last_scheduled_insn)) @@ -3226,7 +3221,8 @@ schedule_block (basic_block *target_bb) /* Update counters, etc in the scheduler's front end. */ (*current_sched_info->begin_schedule_ready) (insn); VEC_safe_push (rtx, heap, scheduled_insns, insn); - last_scheduled_insn = insn; + gcc_assert (NONDEBUG_INSN_P (insn)); + last_nondebug_scheduled_insn = last_scheduled_insn = insn; if (recog_memoized (insn) >= 0) {