public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 4/5] MSP430: Implement TARGET_INSN_COST
Date: Thu, 23 Jul 2020 13:34:22 -0500	[thread overview]
Message-ID: <20200723183422.GE32057@gate.crashing.org> (raw)
In-Reply-To: <20200723155614.jqjgkqtdrnwjahxo@jozef-acer-manjaro>

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

  reply	other threads:[~2020-07-23 18:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 15:43 [PATCH 0/5] MSP430: Implement macros to describe relative costs of operations Jozef Lawrynowicz
2020-07-23 15:47 ` [PATCH 1/5] MSP430: Implement TARGET_MEMORY_MOVE_COST Jozef Lawrynowicz
2020-07-23 15:49 ` [PATCH 2/5] MSP430: Implement TARGET_RTX_COSTS Jozef Lawrynowicz
2020-07-23 15:54 ` [PATCH 3/5] MSP430: Add defaulting to the insn length attribute Jozef Lawrynowicz
2020-07-23 15:56 ` [PATCH 4/5] MSP430: Implement TARGET_INSN_COST Jozef Lawrynowicz
2020-07-23 18:34   ` Segher Boessenkool [this message]
2020-07-24 11:50     ` Jozef Lawrynowicz
2020-07-24 12:25       ` Segher Boessenkool
2020-07-23 15:57 ` [PATCH 5/5] MSP430: Skip index-1.c test Jozef Lawrynowicz
2020-08-07 11:02 ` ping [PATCH 0/5] MSP430: Implement macros to describe relative costs of operations Jozef Lawrynowicz
2020-09-15 20:30   ` ping x2 " Jozef Lawrynowicz
2020-10-14 15:31     ` ping x3 " Jozef Lawrynowicz
2020-11-06 20:51       ` ping x4 " Jozef Lawrynowicz
2020-11-06 20:53     ` ping x2 " Jeff Law
2020-11-06 21:23       ` Jozef Lawrynowicz
2020-11-06 21:29         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200723183422.GE32057@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).