public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "manolis.tsamis at vrull dot eu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/114010] Unwanted effects of using SSA free lists.
Date: Wed, 21 Feb 2024 12:03:27 +0000	[thread overview]
Message-ID: <bug-114010-4-oE8NLTVmrp@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114010-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114010

--- Comment #4 from Manolis Tsamis <manolis.tsamis at vrull dot eu> ---
Hi Andrew,

Thank for your insights on this. Let me reply to some of your points:

(In reply to Andrew Pinski from comment #1)
> >The most important case I have observed is that the vectorizer can fail or create inferior code with more shuffles/moves when the SSA names aren't monotonically increasing.
> 
> That should not be true.

Indeed, after further cleaning-up the dumps, some differences that I was
considering were just due to the diff algorithm not doing a good job and that
confused me (sigh).

So, for this example while we're in tree form I observe only naming changes,
but no different code or order of statements. 

(In reply to Andrew Pinski from comment #2)
> Note what I had found in the past it is not exactly SSA_NAMEs that cause the
> difference but rather the RTL register pesdu # causes differences in
> register allocation which was exposed from the different in operands
> canonicalization.

Yes, I have also observed this and it looks to be the main issue.

(In reply to Andrew Pinski from comment #3)
> The first example (of assembly here) in comment #0 is extra moves due to the
> RA not handling subreg that decent for the load/store lane. There are other
> bug reports dealing with that. Why the SSA_NAMES being monotonically help is
> just by an accident really. 
> 
> 

Do you happen to recall the relevant ticket(s)? I would like to have a look but
couldn't find them so far.

Also, while I agree than in some cases changes like this 'just happen' to
improve codegen in some particular case, it was in multiple experiments that
vectorized code was superior with sorted names and it never was worse with
sorted names. In most cases that I recall the version that used unsorted names
had additional shuffles of different sorts or moves. So, which anecdotal, the
effects doesn't look accidental to me in this case. I feel like there may be
some subtle difference due to the names that helps in this case?

> 
> Also:
> > This mostly affects all the bitmaps that use SSA_NAME_VERSION as a key.
> 
> Most use sparse bitmaps there so it is not a big deal.
> 

Agreed and that's probably why I couldn't measure any non-trivial difference in
compilation times.

I should just note that there are also places that create vectors or other data
structures sized to the number of ssa_names, so in theory this could still help
in extreme cases.

> I think this should be split up in a few different bug reports really.
> One for each case where better optimizations happen.
> 
Ok, the only cases that I found to be clearly better are the ones related to
vectorization. Would it help to create a ticket just for that now, or should I
wait for the discussion in this one to conclude first?

> Also:
> >I have seen two similar source files generating the exact same GIMPLE code up to some optimization pass but then completely diverging due to different freelists.
> 
> The only case where I have seen this happen is expand will have different
> pesdu # really. Yes I noticed this effect while I did
> r14-569-g21e2ef2dc25de3 really.

Afaik, the codegen differences that I observed was due to the same reason, but
it nonetheless felt weird that the same GIMPLE could produce two different
w.r.t. name ordering files later on just because the freelists were different
(but invisible in the dumps). So I naturally questioned 'why don't we just
flush the freelists after every pass if it's not a performance issue'?

  parent reply	other threads:[~2024-02-21 12:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 10:22 [Bug tree-optimization/114010] New: " manolis.tsamis at vrull dot eu
2024-02-21  0:06 ` [Bug tree-optimization/114010] " pinskia at gcc dot gnu.org
2024-02-21  0:11 ` pinskia at gcc dot gnu.org
2024-02-21  0:22 ` pinskia at gcc dot gnu.org
2024-02-21 12:03 ` manolis.tsamis at vrull dot eu [this message]
2024-02-21 12:09 ` manolis.tsamis at vrull dot eu
2024-02-22  1:02 ` ptomsich at gcc dot gnu.org
2024-02-22  1:02 ` ptomsich at gcc dot gnu.org
2024-02-22 10:28 ` rguenth at gcc dot gnu.org
2024-02-23 14:31 ` ptomsich at gcc dot gnu.org
2024-02-23 15:02 ` manolis.tsamis at vrull dot eu

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=bug-114010-4-oE8NLTVmrp@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).