From: Hans-Peter Nilsson <hp@axis.com>
To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Cc: <paulkoning@comcast.net>, <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v3] doc: Document order of define_peephole2 scanning
Date: Thu, 20 Apr 2023 04:57:18 +0200 [thread overview]
Message-ID: <20230420025718.B71B220416@pchp3.se.axis.com> (raw)
In-Reply-To: <8809BA90-313A-4C8B-A684-0664E1F6AD66@gmail.com> (message from Bernhard Reutner-Fischer on Wed, 19 Apr 2023 22:16:36 +0200)
> Date: Wed, 19 Apr 2023 22:16:36 +0200
> From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
> On 19 April 2023 21:21:18 CEST, Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> wrote:
> >Hi H-P!
> >
> >This begs the question iff now (i fear it's not), upon
> >successful match(es), the whole peepholes get re-run
> >again per BB (ATM?), exposing more opportunities?
(Not sure IIUC the question, but:) no; as mentioned the
peephole2 machinery doesn't back up to include the context
of longer sequences when having done replacement for a
shorter match. It resumes matching at the beginning of the
shorter, matched and replaced, sequence.
> >If not, would we want to retry, at least for
> >-fexpensive-optimisations (sp?) or would all hell break
> >loose?
I don't think hell would break loose, but maybe slowdown
and/or buggy define_peephole2s would be weeded out. Or
something else entirely unexpected. :)
> >Please also see below.
> >
> >On 19 April 2023 18:59:14 CEST, Hans-Peter Nilsson via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> >>Anyway, the missing-context problem I ran into remains: if
> >>you have an insn sequence {foo bar} and a define_peephole2
> >>matching and replacing {bar} into {baz}, the resulting {foo
> >>baz} *will not be matched* against a define_peephole2
> >>looking for {foo baz}. But, I'm not trying to document this
> >>caveat specifically, though at least it'll now be implied by
> >>the documentation.
> >>
> >>This could be fixed by always backing up MAX_INSNS_PER_PEEP2
> >>- 1 insns after a successful replacement. I'm somewhat
> >>worries that this would also mean lots of futile re-match
> >>attempts. Thoughts?
> >
> >Good point. Probably. Do you have stats?
None whatsoever. I'm going to test with the "original"
define_peephole2 for CRIS that was suffering, but with an
"extra" define_peephole2 that also does the modification for
the one that caused it do be missed and see if the original
free one still fires off. (I see I cut down my foo bar baz
examples too much to make sense to explain that.)
> >If there is even a slight benefit, then some certainly
> >would be willing to take that penalty for sure. I.e. iff
> >it helps -Os or locality then such expensive
> >optimisations certainly provide benefit for at least a
> >few if not some, IMO.
Right. Not sure I'll be doing it though, having other
things, gcc-related and others, on my plate. If so, first
I'd do a crude attempt at getting statistics for x86_64, by
after a successful replacement, restarting at the beginning
of a BB and checking whether any define_peephole2 fires off
before reaching the first replaced insn.
brgds, H-P
next prev parent reply other threads:[~2023-04-20 2:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 17:55 [PATCH] " Hans-Peter Nilsson
2023-04-18 18:32 ` Paul Koning
2023-04-18 18:44 ` Hans-Peter Nilsson
2023-04-19 3:15 ` [PATCH v2] " Hans-Peter Nilsson
2023-04-19 4:06 ` Hans-Peter Nilsson
2023-04-19 16:59 ` [PATCH v3] " Hans-Peter Nilsson
[not found] ` <4E63CF4D-C355-4053-8EA4-5700C1B938E3@gmail.com>
2023-04-19 20:16 ` Bernhard Reutner-Fischer
2023-04-20 2:57 ` Hans-Peter Nilsson [this message]
2023-04-26 23:55 ` Ping: " Hans-Peter Nilsson
2023-05-04 0:09 ` 2nd " Hans-Peter Nilsson
2023-05-04 9:45 ` Richard Biener
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=20230420025718.B71B220416@pchp3.se.axis.com \
--to=hp@axis.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=paulkoning@comcast.net \
--cc=rep.dot.nop@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).