public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Roger Sayle <roger@nextmovesoftware.com>
Cc: gcc-patches@gcc.gnu.org
Subject: RE: [PATCH] Move reload_completed and other rtl.h globals to crtl structure.
Date: Mon, 11 Jul 2022 09:42:09 +0000 (UTC)	[thread overview]
Message-ID: <nycvar.YFH.7.77.849.2207110927260.14950@jbgna.fhfr.qr> (raw)
In-Reply-To: <020401d89500$e3f6ca90$abe45fb0$@nextmovesoftware.com>

On Mon, 11 Jul 2022, Roger Sayle wrote:

> On 11 July 2022 08:20, Richard Biener wrote:
> > On Sun, 10 Jul 2022, Roger Sayle wrote:
> > 
> > > This patch builds upon Richard Biener's suggestion of avoiding global
> > > variables to track state/identify which passes have already been run.
> > > In the early middle-end, the tree-ssa passes use the curr_properties
> > > field in cfun to track this.  This patch uses a new rtl_pass_progress
> > > int field in crtl to do something similar.
> > 
> > Why not simply add PROP_rtl_... and use the existing curr_properties for
> this?
> > RTL passes are also passes and this has the advantage you can add things
> like
> > reload_completed to the passes properties_set field hand have the flag
> setting
> > handled by the pass manager as it was intended?
> > 
> 
> Great question, and I did initially consider simply adding more RTL fields
> to
> curr_properties.  My hesitation was from the comments/documentation that
> the curr_properties field is used by the pass manager as a way to track
> (and verify) the properties/invariants that are required, provided and
> destroyed
> by each pass.  This semantically makes sense for properties such as accurate
> data flow, ssa form, cfg_layout, nonzero_bits etc, where hypothetically the
> pass manager can dynamically schedule a pass/analysis to ensure the next
> pass
> has the pre-requisite information it needs.

Yeah, that might have been some of the design inspiring bits but
actually the pass manager does nothing of this sorts instead it
only verifies the statically scheduled producers/consumers match
expectations ...

We also track in these bits how the IL evolves from high to low
GIMPLE, to CFG/SSA, to after the point where complex or vector ops
are lowered, etc.  To me whether we've assigned hard regs (after-reload)
is quite similar, the after_combine would be similar to
PROP_gimple_opt_math.  You've already found PROP_rtl_split_insns.

> This seems semantically slightly different from tracking time/progress,
> where
> we really want something more like DEBUG_COUNTER that simply provides
> the "tick-tock" of a pass clock.  Alas, the "pass number", as used in the
> suffix
> of dump-files (where 302 currently means reload) isn't particularly useful
> as
> these change/evolve continually.
> 
> Perhaps the most obvious indication of this (subtle) difference is the
> curr_properties field (PROP_rtl_split_insns) which tracks whether
> instructions
> have been split, where at a finer granularity rtl_pass_progress may wish to
> distinguish split1 (after combine before reload), split2 (after reload
> before
> peephole2) and split3 (after peephole2).  It's conceptually not a simple
> property, whether all insns have been split or not, as in practice this is
> more subtle with backends choosing which instructions get split at which
> "times".

I'm not sure it's good to allow such fine-grained control since it
makes the pass pipeline x N-target.md a quite fragile setup.  You
could argue you want such flag on the actual RTL insn
(was-split-from-insn-X) even ...

> There's also the concern that we've a large number of passes (currently
> 62 RTL passes), and only a finite number of bits (in curr_properties), so
> having two integers reduces the risk of running out of bits and needing
> to use a "wider" data structure.

As said whether an individual pass has run or not is not what this
bitmask is for nor is it what we should do.  We should provide a more
abstract thing to test for and I doubt we can make one for each of the
62 RTL passes ;)

> To be honest, I just didn't want to hijack curr_properties to abuse it for a
> 
> use that didn't quite match the original intention, without checking with
> you and the other maintainers first.  If the above reasoning isn't
> convincing,
> I can try spinning an alternate patch using curr_properties (but I'd expect
> even more churn as backend source files would now need to #include
> tree-passes.h and function.h to get reload_completed).  And of course,
> a volunteer is welcome to contribute that re-refactoring after this one.
>
> I've no strong feelings either way.  It was an almost arbitrary engineering
> decision (but hopefully the above explains the balance of my reasoning).

I definitely lean towards using curr_properties and new PROP_rtl_...,
but if anybody else has opposite views I won't insist.

+  /* Track progress of RTL passes, reload_completed etc.  */
+  int rtl_pass_progress;

btw, this suggests that we don't need a bitmask but instead can define
a strong order, making the tests with a relational compare?  The
reason we do not have this with PROP_ is twofold, one, we're mixing
with flags that come and go away, second, some of the "order" stuff
might depend on the optimization level since we have separate
pipelines for -O0 and -O1 (and -Og) and whether for example complex
or vectors are lowered might happen in different order (I didn't
actually check whether that's the case right now).  It might suggest
that splitting up curr_properties is a good idea (maybe then
rename rtl_pass_progress to pass_progress so we can reuse it there).

Richard.

> Roger
> --
> 
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Frankenstra

  reply	other threads:[~2022-07-11  9:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-10 18:19 Roger Sayle
2022-07-11  7:20 ` Richard Biener
2022-07-11  8:33   ` Roger Sayle
2022-07-11  9:42     ` Richard Biener [this message]
2022-07-11 11:44     ` Richard Sandiford
2022-07-11 20:31 ` Jeff Law
2022-09-28  1:16 ` 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=nycvar.YFH.7.77.849.2207110927260.14950@jbgna.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=roger@nextmovesoftware.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).