public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Stubbs <ams@codesourcery.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc mailing list <gcc@gcc.gnu.org>
Subject: Re: Register allocation cost question
Date: Wed, 11 Oct 2023 09:57:46 +0100	[thread overview]
Message-ID: <8df01cc8-7662-450b-b183-b9be96df26fb@codesourcery.com> (raw)
In-Reply-To: <20231010190930.GV19790@gate.crashing.org>



On 10/10/2023 20:09, Segher Boessenkool wrote:
> Hi Andrew,
> 
> On Tue, Oct 10, 2023 at 04:11:18PM +0100, Andrew Stubbs wrote:
>> I'm also seeing wrong-code bugs when I allow more than 32 new registers,
>> but that might be an unrelated problem. Or the allocation is broken? I'm
>> still analyzing this.
> 
> It could be connected.  both things should not happen.
> 
>> If it matters, ... the new registers can't be used for general purposes,
> 
> What does this mean?  I think you mean they *can* be used for anything,
> you just don't want to (maybe it is slow)?  If you make it allocatable
> registers, they *will* be allocated for anythin the compilers deems a
> good idea.

Nope, the "Accelerator VGPR" registers are exclusively for the use of 
the new matrix multiply instructions that we don't support (yet).

The compiler is free to use them for storing data, but there are no real 
instructions to do there.

>> so I'm trying to set them up as a temporary spill destination. This
>> means they're typically not busy. It feels like it shouldn't be this
>> hard... :(
> 
> So what did you do, put them later in the allocation order?  Make their
> register_move_cost higher than for normal registers (but still below
> memory_move_cost)?  Or what?  TARGEt_SPILL_CLASS maybe?

We put them in a new register class, with a new constraint, and 
implemented the move instructions (only) with new alternatives for the 
new class. Then implemented TARGET_SPILL_CLASS in the obvious way.

All this is working just fine as long as there are only 32 new registers 
unfixed (a0-a31); the code even runs correctly and I can see the 
spilling happening correctly.

If I enable register a32 then it prefers that, and I get wrong code. 
Using that register ought to be logically correct, albeit suboptimal, so 
I don't understand that either.

Andrew

  reply	other threads:[~2023-10-11  8:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10 15:11 Andrew Stubbs
2023-10-10 19:09 ` Segher Boessenkool
2023-10-11  8:57   ` Andrew Stubbs [this message]
2023-10-11 14:49   ` Andrew Stubbs
2023-10-11  6:54 ` Chung-Lin Tang
2023-10-11  8:58   ` Andrew Stubbs
2023-10-11 10:56     ` Richard Earnshaw (lists)

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=8df01cc8-7662-450b-b183-b9be96df26fb@codesourcery.com \
    --to=ams@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=segher@kernel.crashing.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).