public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@redhat.com>
To: Michael Clark <michaeljclark@mac.com>,
	Leslie Zhai <lesliezhai@llvm.org.cn>
Cc: LewisR9@cf.ac.uk, dag@cray.com, stoklund@2pi.dk,
	GCC Development <gcc@gcc.gnu.org>,
	LLVM Developers Mailing List <llvm-dev@lists.llvm.org>
Subject: Re: Register Allocation Graph Coloring algorithm and Others
Date: Tue, 19 Dec 2017 04:16:00 -0000	[thread overview]
Message-ID: <addd0ae1-11cc-31eb-157c-df5eea0d2792@redhat.com> (raw)
In-Reply-To: <62E41783-1145-4036-9FD4-75D3B0C22DE6@mac.com>



On 12/18/2017 07:07 PM, Michael Clark wrote:
> Hi Leslie,
>
> I suggest adding these 3 papers to your reading list.
>
> 	Register allocation for programs in SSA-form
> 	Sebastian Hack, Daniel Grund, and Gerhard Goos
> 	http://www.rw.cdl.uni-saarland.de/~grund/papers/cc06-ra_ssa.pdf
>
> 	Simple and Efficient Construction of Static Single Assignment Form
> 	Matthias Braun , Sebastian Buchwald , Sebastian Hack , Roland Leißa , Christoph Mallon , and Andreas Zwinkau
> 	https://www.info.uni-karlsruhe.de/uploads/publikationen/braun13cc.pdf
>
> 	Optimal register allocation for SSA-form programs in polynomial time
> 	Sebastian Hack, Gerhard Goos
> 	http://web.cs.ucla.edu/~palsberg/course/cs232/papers/HackGoos-ipl06.pdf
>
> A lot of the earlier literature regarding the register allocation problem describes the general graph colouring problem as NP-complete, however previous research in Register Allocation has been in the context of programs that were not in SSA form. i.e. the Chaitin-Briggs paper states that register allocation is NP-complete and proposes an iterative algorithm.
>
>
I am sceptical about SSA-register allocators for high quality code 
generation.  But I should acknowledge although I tried a lot of RA 
algorithms I never tried SSA one.

One task of RA is to deal with moves but when you are destroying SSA you 
are creating moves or swaps.  Of course there are optimizations to 
decrease its number when you are going out of SSA.  But IMHO a good RA 
should see all moves created before or during own work.

As I already wrote coloring is just one out of many task of RA.  All 
these tasks in a good RA should be solved in cooperation. Optimistic 
coloring is good and fast enough (although building a conflict graph for 
it takes a lot of time).  I think better results can be obtained by 
improving other tasks than by improving optimistic coloring.

For example, nobody mentioned irregular file architectures (with 
subregisters and register subclasses) like x86/x86-64.  Even regular 
file architectures with caller/callee saved hard registers have 
irregularity because it creates register subclasses, e.g. class of saved 
general registers is a subclass of the overall general register class.  
Usually hard registers are present in IR and if some pseudos conflict 
with the hard registers, it also create a lot (intersected) subclasses.

Taking such irregularity, e.g. in coloring criteria based on Kempe's 
heuristic, can improve the final RA significantly (as I remember GCC 
generated code for SPECInt2000 even on ppc64 with mostly regular 
register file was improved by 1% by taking such subclasses into account 
during coloring). A classical article about this 
https://www.researchgate.net/publication/2440424_Graph-Coloring_Register_Allocation_for_Irregular_Architectures 
could be a start point for such implementation.

  parent reply	other threads:[~2017-12-19  4:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <615F0DCE4D5873A9@mac.com>
2017-12-19  0:07 ` Michael Clark
2017-12-19  2:10   ` Leslie Zhai
2017-12-19  4:16   ` Vladimir Makarov [this message]
2017-12-19 20:24     ` [llvm-dev] " Matthias Braun
2017-12-15  3:19 Leslie Zhai
2017-12-15  4:40 ` Vladimir Makarov
2017-12-15  4:59   ` Leslie Zhai
2017-12-15 14:48 ` Peter Bergner
2017-12-18 16:42 ` dag
2017-12-18 17:52   ` Leslie Zhai
2017-12-18 22:35     ` dag
     [not found]   ` <9CBFCADA170A6854@apple.com>
     [not found]     ` <6708A731-203E-4096-8137-85D4104DA035@apple.com>
2017-12-19  3:03       ` [llvm-dev] " Leslie Zhai
2017-12-20 17:25         ` Jakob Stoklund Olesen
2017-12-21  0:44           ` Leslie Zhai

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=addd0ae1-11cc-31eb-157c-df5eea0d2792@redhat.com \
    --to=vmakarov@redhat.com \
    --cc=LewisR9@cf.ac.uk \
    --cc=dag@cray.com \
    --cc=gcc@gcc.gnu.org \
    --cc=lesliezhai@llvm.org.cn \
    --cc=llvm-dev@lists.llvm.org \
    --cc=michaeljclark@mac.com \
    --cc=stoklund@2pi.dk \
    /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).