From patchwork Fri Oct 10 08:17:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhenqiang Chen X-Patchwork-Id: 398490 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C9610140095 for ; Fri, 10 Oct 2014 19:17:49 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=T/SXGR3K0dIwbMICNdQvvzWDEfSkVZqKqkrGCBJbAcfX9uuJGbT0M brE6j3CRisMMQPKKUmXdCGTlK+kY1qLqriSAIyYjWPXKUUzTAnb36z+nOyHDL6Ce qBbjrzR5TSsD6GZPeFEn0VUvMZL3YhueuHDAtQPPq+O5xc96+FOxxg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=Xdrg67RE51XwfBpYFhoxqRXchV8=; b=mnEMgqSzg+mPWrxcmwu8Yf4I0473 j3Hn0LpCkxbRFnvZKkrZ/z22JrHYN4ANuuPfFEEoRAjluq3mOzh6z6q7K7Ayq4NB apzgFh7WfO0CURqonbWLLMWjE9E1adjAJXt5nKIHiNr4Q5Upnf8RBtHkO4Nd6qvo zVQq6vmnoI/I7ow= Received: (qmail 1218 invoked by alias); 10 Oct 2014 08:17:42 -0000 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 Received: (qmail 1192 invoked by uid 89); 10 Oct 2014 08:17:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Oct 2014 08:17:40 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 10 Oct 2014 09:17:37 +0100 Received: from shawin003 ([10.164.2.49]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 10 Oct 2014 09:17:34 +0100 From: "Zhenqiang Chen" To: "'Richard Biener'" Cc: "GCC Patches" References: <000001cfe3a1$5e7c7bd0$1b757370$@arm.com> In-Reply-To: Subject: RE: [PATCH] Clean up duplicated function seq_cost Date: Fri, 10 Oct 2014 16:17:23 +0800 Message-ID: <000001cfe462$9fbc7610$df356230$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114101009173702201 X-IsSubscribed: yes > -----Original Message----- > From: Richard Biener [mailto:richard.guenther@gmail.com] > Sent: Thursday, October 09, 2014 5:21 PM > To: Zhenqiang Chen > Cc: GCC Patches > Subject: Re: [PATCH] Clean up duplicated function seq_cost > > On Thu, Oct 9, 2014 at 11:20 AM, Richard Biener > wrote: > > On Thu, Oct 9, 2014 at 11:14 AM, Zhenqiang Chen > wrote: > >> Hi, > >> > >> The are two implementations of seq_cost. The function bodies are > >> exactly the same. The patch removes one of them and make the other > global. > >> > >> Bootstrap and no make check regression on X86-64. > >> > >> OK for trunk? > > > > The prototype should go to cfgloopanal.c. > > Err - cfgloopanal.h of course ;) Or rather the function sounds misplaced in > cfgloopanal.c. Thanks for the comments. I think seq_cost should be in rtlanal.c, just like rtx_cost, insn_rtx_cost and so on. ChangeLog: 2014-10-10 Zhenqiang Chen * cfgloopanal.c (seq_cost): Delete. * rtl.h (seq_cost): New prototype. * rtlanal.c (seq_cost): New function. * tree-ssa-loop-ivopts.c (seq_cost): Delete. diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index 7ea1a5f..006b419 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -302,26 +302,6 @@ get_loop_level (const struct loop *loop) return mx; } -/* Returns estimate on cost of computing SEQ. */ - -static unsigned -seq_cost (const rtx_insn *seq, bool speed) -{ - unsigned cost = 0; - rtx set; - - for (; seq; seq = NEXT_INSN (seq)) - { - set = single_set (seq); - if (set) - cost += set_rtx_cost (set, speed); - else - cost++; - } - - return cost; -} - /* Initialize the constants for computing set costs. */ void diff --git a/gcc/rtl.h b/gcc/rtl.h index e73f731..b697417 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2921,6 +2921,7 @@ extern rtx_insn *find_first_parameter_load (rtx_insn *, rtx_insn *); extern bool keep_with_call_p (const rtx_insn *); extern bool label_is_jump_target_p (const_rtx, const rtx_insn *); extern int insn_rtx_cost (rtx, bool); +extern unsigned seq_cost (const rtx_insn *, bool); /* Given an insn and condition, return a canonical description of the test being made. */ diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 3063458..93eda12 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -5017,6 +5017,26 @@ insn_rtx_cost (rtx pat, bool speed) return cost > 0 ? cost : COSTS_N_INSNS (1); } +/* Returns estimate on cost of computing SEQ. */ + +unsigned +seq_cost (const rtx_insn *seq, bool speed) +{ + unsigned cost = 0; + rtx set; + + for (; seq; seq = NEXT_INSN (seq)) + { + set = single_set (seq); + if (set) + cost += set_rtx_cost (set, speed); + else + cost++; + } + + return cost; +} + /* Given an insn INSN and condition COND, return the condition in a canonical form to simplify testing by callers. Specifically: diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 400798a..087ca26 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -2842,26 +2842,6 @@ get_use_iv_cost (struct ivopts_data *data, struct iv_use *use, return NULL; } -/* Returns estimate on cost of computing SEQ. */ - -static unsigned -seq_cost (rtx_insn *seq, bool speed) -{ - unsigned cost = 0; - rtx set; - - for (; seq; seq = NEXT_INSN (seq)) - { - set = single_set (seq); - if (set) - cost += set_src_cost (SET_SRC (set), speed); - else - cost++; - } - - return cost; -} - /* Produce DECL_RTL for object obj so it looks like it is stored in memory. */ static rtx produce_memory_decl_rtl (tree obj, int *regno)