From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id B17463857C4E for ; Thu, 23 Jul 2020 18:34:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B17463857C4E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 06NIYNUh008807 for ; Thu, 23 Jul 2020 13:34:24 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 06NIYNsV008802 for gcc-patches@gcc.gnu.org; Thu, 23 Jul 2020 13:34:23 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 23 Jul 2020 13:34:22 -0500 From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 4/5] MSP430: Implement TARGET_INSN_COST Message-ID: <20200723183422.GE32057@gate.crashing.org> References: <20200723154356.63ws2xairlmdufji@jozef-acer-manjaro> <20200723155614.jqjgkqtdrnwjahxo@jozef-acer-manjaro> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723155614.jqjgkqtdrnwjahxo@jozef-acer-manjaro> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jul 2020 18:34:26 -0000 Hi! On Thu, Jul 23, 2020 at 04:56:14PM +0100, Jozef Lawrynowicz wrote: > +static int > +msp430_insn_cost (rtx_insn *insn, bool speed ATTRIBUTE_UNUSED) > +{ > + int cost; > + > + if (recog_memoized (insn) < 0) > + return 0; > + > + cost = get_attr_length (insn); > + if (TARGET_DEBUG_INSN_COSTS) > + { > + fprintf (stderr, "cost %d for insn:\n", cost); > + debug_rtx (insn); > + } > + > + /* The returned cost must be relative to COSTS_N_INSNS (1). An insn with a > + length of 2 bytes is the smallest possible size and so must be equivalent > + to COSTS_N_INSNS (1). */ > + return COSTS_N_INSNS (cost) / (2 * COSTS_N_INSNS (1)); This is the same as "cost / 2", so "length / 2" here, which doesn't look right. The returned value should have the same "unit" as COSTS_N_INSNS does, so maybe you want COSTS_N_INSNS (length / 2) ? > + /* FIXME Add more detailed costs when optimizing for speed. > + For now the length of the instruction is a good approximiation and roughly > + correlates with cycle cost. * COSTS_N_INSNS (1) is 4, so that you can make things cost 5, 6, 7 to be a cost intermediate to COSTS_N_INSNS (1) and COSTS_N_INSNS (2). This is very useful, scaling down the costs destroys that. > +mdebug-insn-costs > +Target Report Mask(DEBUG_INSN_COSTS) > +Print insns and their costs as calculated by TARGET_INSN_COSTS. It is already printed in the generated asm with -dp? Not sure if you want more detail than that. '-dp' Annotate the assembler output with a comment indicating which pattern and alternative is used. The length and cost of each instruction are also printed. Segher