public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
To: Richard Biener <richard.guenther@gmail.com>,
	Kugan Vivekanandarajah	<kugan.vivekanandarajah@linaro.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, nd <nd@arm.com>
Subject: Re: [RFC] Tree loop unroller pass
Date: Fri, 16 Feb 2018 14:22:00 -0000	[thread overview]
Message-ID: <DB6PR0801MB20531444EF35A79FC97C059D83CB0@DB6PR0801MB2053.eurprd08.prod.outlook.com> (raw)
In-Reply-To: <CAFiYyc1MOhnib68UHRBtb6=RGRe17d-qtWReWgy+1brvezQPxw@mail.gmail.com>

Richard Biener wrote:
>> This is a great plan - GCC urgently requires a good unroller!
>
> How so?

I thought it is well-known for many years that the rtl unroller doesn't work properly.
In practically all cases where LLVM beats GCC, it is due to unrolling small loops.

You may have noticed how people have been enabling -fprefetch-loop-arrays by
default in some AArch64 configurations and then strip out most/all prefetches in
order to get the effect of tree unrolling... However the unroll parameters of this
pass are even worse than -funroll-loops, so it ends up using crazy unroll factors.

> To generate more ILP for modern out-of-order processors you need to be
> able to do followup transforms that remove dependences.  So rather than
> inventing magic params we should look at those transforms and key
> unrolling on them.  Like we do in predictive commoning or other passes
> that end up performing unrolling as part of their transform.

This is why unrolling needs to be done at the tree level. Alias info is correct,
addressing modes end up more optimal and the scheduler can now interleave 
the iterations (often not possible after the rtl-unroller due to bad alias info).
 
> Our measurements on x86 concluded that unrolling isn't worth it, in fact
> it very often hurts.  That was of course with saner params than the defaults
> of the RTL unroller.
>
> Often you even have to fight with followup passes doing stuff that ends up
> inreasing register pressure too much so we end up spilling.

Yes that's why I mentioned we should only unroll small loops where there
is always a benefit from reduced loop counter increments and branching.

> So _please_ first get testcases we know unrolling will be beneficial on
> and _also_ have a thorough description _why_.

I'm sure we can find good examples. The why will be obvious just from instruction
count.

Wilco

  reply	other threads:[~2018-02-16 14:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13 13:05 Wilco Dijkstra
2018-02-15 22:31 ` Kugan Vivekanandarajah
2018-02-16 11:56   ` Richard Biener
2018-02-16 14:22     ` Wilco Dijkstra [this message]
2018-02-16 15:00       ` Richard Biener
2018-02-16 15:32         ` Wilco Dijkstra
2018-02-20 15:46       ` Michael Matz
2018-02-20  0:17     ` Kugan Vivekanandarajah
  -- strict thread matches above, loose matches on Subject: below --
2018-02-12 23:56 [RFC] Tree Loop Unroller Pass Kugan Vivekanandarajah
2018-02-20 19:53 ` Andrew Pinski
2018-02-12 23:52 [RFC] Tree loop unroller pass Kugan Vivekanandarajah

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=DB6PR0801MB20531444EF35A79FC97C059D83CB0@DB6PR0801MB2053.eurprd08.prod.outlook.com \
    --to=wilco.dijkstra@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kugan.vivekanandarajah@linaro.org \
    --cc=nd@arm.com \
    --cc=richard.guenther@gmail.com \
    /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).