From patchwork Tue May 10 15:24:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 95072 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 12FEBB6EF1 for ; Wed, 11 May 2011 17:33:49 +1000 (EST) Received: (qmail 30749 invoked by alias); 10 May 2011 15:25:47 -0000 Received: (qmail 30724 invoked by uid 22791); 10 May 2011 15:25:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 15:25:28 +0000 Received: (qmail 27835 invoked from network); 10 May 2011 15:25:27 -0000 Received: from unknown (HELO ?84.152.158.68?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 10 May 2011 15:25:27 -0000 Message-ID: <4DC958C6.3000808@codesourcery.com> Date: Tue, 10 May 2011 17:24:54 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: GCC Patches Subject: C6X port 3/11: Cache dependency costs References: <4DC956D0.3040306@codesourcery.com> In-Reply-To: <4DC956D0.3040306@codesourcery.com> 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 Jeff already approved this one a while ago. I haven't applied it yet because so far it hasn't been necessary, but it will help for the backtracking scheduler. Bernd * sched-int.h (struct _dep): Add member cost. (DEP_COST, UNKNOWN_DEP_COST): New macros. * sched-deps.c (init_dep_1): Initialize DEP_COST. * haifa-sched.c (dep_cost_1): Use and set DEP_COST. Index: gcc/haifa-sched.c =================================================================== --- gcc.orig/haifa-sched.c +++ gcc/haifa-sched.c @@ -855,6 +855,9 @@ dep_cost_1 (dep_t link, dw_t dw) rtx used = DEP_CON (link); int cost; + if (DEP_COST (link) != UNKNOWN_DEP_COST) + return DEP_COST (link); + /* A USE insn should never require the value used to be computed. This allows the computation of a function's result and parameter values to overlap the return and call. We don't care about the @@ -912,6 +915,7 @@ dep_cost_1 (dep_t link, dw_t dw) cost = 0; } + DEP_COST (link) = cost; return cost; } @@ -4874,11 +4878,20 @@ fix_recovery_deps (basic_block rec) void sched_change_pattern (rtx insn, rtx new_pat) { + sd_iterator_def sd_it; + dep_t dep; int t; t = validate_change (insn, &PATTERN (insn), new_pat, 0); gcc_assert (t); dfa_clear_single_insn_cache (insn); + + for (sd_it = sd_iterator_start (insn, SD_LIST_FORW | SD_LIST_BACK); + sd_iterator_cond (&sd_it, &dep);) + { + DEP_COST (dep) = UNKNOWN_DEP_COST; + sd_iterator_next (&sd_it); + } } /* Change pattern of INSN to NEW_PAT. Invalidate cached haifa Index: gcc/sched-deps.c =================================================================== --- gcc.orig/sched-deps.c +++ gcc/sched-deps.c @@ -107,6 +107,7 @@ init_dep_1 (dep_t dep, rtx pro, rtx con, DEP_CON (dep) = con; DEP_TYPE (dep) = type; DEP_STATUS (dep) = ds; + DEP_COST (dep) = UNKNOWN_DEP_COST; } /* Init DEP with the arguments. Index: gcc/sched-int.h =================================================================== --- gcc.orig/sched-int.h +++ gcc/sched-int.h @@ -239,6 +239,9 @@ struct _dep /* Dependency status. This field holds all dependency types and additional information for speculative dependencies. */ ds_t status; + + /* Cached cost of the dependency. */ + int cost; }; typedef struct _dep dep_def; @@ -248,6 +251,9 @@ typedef dep_def *dep_t; #define DEP_CON(D) ((D)->con) #define DEP_TYPE(D) ((D)->type) #define DEP_STATUS(D) ((D)->status) +#define DEP_COST(D) ((D)->cost) + +#define UNKNOWN_DEP_COST INT_MIN /* Functions to work with dep. */