public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Reshabh K Sharma <reshabh@cs.washington.edu>
Cc: Jeff Law <jeffreyalaw@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: Describe instructions with same reg in def and use or mutiple defs and attach write latency
Date: Thu, 17 Feb 2022 12:48:46 -0600	[thread overview]
Message-ID: <20220217184846.GN614@gate.crashing.org> (raw)
In-Reply-To: <CAAhFPT2=c8M0VzmGmt+gQGLfp-+LiJpQPVzuXvq03aC7gSHENQ@mail.gmail.com>

On Wed, Feb 16, 2022 at 11:41:37AM -0800, Reshabh K Sharma wrote:
> I wanted to add scheduling cost to rd and rs, I was suggested to use
> TARGET_SCHED_ADJUST_COST but there I need to check if the instruction is
> FLWR and as suggested I tried using get_attr_type. I realized that first I
> need to set the type then use get_attr_type. I also couldn't find any other
> place to set the attribute other than define_insn but this custom
> instruction was just going to be used in inline asm right now so there was
> no equivalent rtl from which I can lower into this but since I was not able
> to find any other way to set the attribute, I decided to add a pattern
> (hoping it to be unmatchable) where I could add the attribute, so inside
> riscv.md I added the define_insn for flwr and used set_attr but I'm not
> able to find any instruction in the TARGET_SCHED_ADJUST_COST for the
> specific type attr.
> 
> 1. Does inline asm compilation flow goes through the
> TARGET_SCHED_ADJUST_COST?
> 2. Is there a better way to do this? / Am I missing something?

GCC does not look at the assembler template to try to figure out what
instructions are in there.  This is by design.  So, the compiler can
never know much about how it will schedule on the real machine (it does
estimate (pessimistically) how big the resulting machine code will be,
so that any branches can reach their target).

Making a define_insn for your insn is exactly the right plan.  You do
not have too hope it does not accidentally match anything else: if you
make it an unspec, it can never match anything but itself (nothing with
a different "index" number).


Segher

      reply	other threads:[~2022-02-17 18:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27  1:20 Reshabh K Sharma
2022-01-28 17:39 ` Jeff Law
2022-01-28 18:21   ` Segher Boessenkool
2022-02-04  1:06     ` Reshabh K Sharma
2022-02-04  1:31       ` Segher Boessenkool
2022-02-16 19:41         ` Reshabh K Sharma
2022-02-17 18:48           ` Segher Boessenkool [this message]

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=20220217184846.GN614@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=reshabh@cs.washington.edu \
    /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).