public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/106594] [13 Regression] sign-extensions no longer merged into addressing mode
Date: Sun, 05 Mar 2023 15:23:48 +0000	[thread overview]
Message-ID: <bug-106594-4-sa04mFR76q@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106594-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #16 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Roger Sayle from comment #14)
> This really is a regression, that points to a previously latent/unnoticed
> bug in combine.
> 
> In GCC 12, combine would take the input RTL and based on target costs
> transform it into the better of implementation A or B.

And it still does exactly that.  And your patch would *not*!  It does not
compare the cost of two alternative pieces of code; it just says "if the cost
of calculating some RTL expression as separate code is 4 or less, do not do
any other optimisation here".  It is completely ad-hoc, not an improvement,
will only cause more problems in the future.

> Now in GCC 13, the
> tree-optimizers are able to perform this same optimization earlier and so
> combine is now given optimal implementation A,

So it is not a regression in combine.

> where a latent bug always
> transforms this to B without ever checking target costs.

Latent.  It is not a regression.

> The consensus is that performing (more) optimizations at the tree-level is a
> good thing,

No.  The situation is different, not so simplistic.

At tree level the representation is higher level.  At RTL level it is more
nitty-gritty, very *low* level, very close to machine code.  It is very
important to do optimisations at that level as well.  It is pretty much
impossible to do a good job of low-level optimisations (like instruction
selection) at a high level, i.e. at great distance.  It is a bad idea to try
to such things at a high level.  What we can (and should, and *do*) do is
to in higher level optimisations keep code flexible, only have abstractions
that are easy to work with, etc.; and to have earlier passes output code
that the later passes can work with well.

> so reverting changes to the tree optimizers (that now produce
> better code) is a workaround to a glitch where combine is transforming RTL
> into more expensive forms.

But no one is talking about reverting anything?

> There's already a code path in combine that checks/compares costs, it just
> isn't being reached any more.

Now you completely lost me.

> p.s. this has nothing to do with sign_extract/zero_extract, for which
> hardware support would be hypothetical, this patch only affects
> sign_extend/zero_extend, such as aarch64's sxtw or x86_64's movsx or
> powerpc's extsw.  If a target has this functionality, it's unlikely that a
> sequence of shifts or bit-wise operations would be better.

*_extract is just an example (see various open PRs) of the problems with
compound_operation stuff.  I would just rip out all that stuff, similar to
your patch but a bit more drastic, except that causes regressions on other
targets.

Which I have tested and analysed, btw.  As I said in the patch review, this
really needs to be looked at on more targets.  And it should be done in
stage 1, not in stage 4.

(I am running such a test with your patch on all Linux targets, fwiw).

  parent reply	other threads:[~2023-03-05 15:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 11:23 [Bug tree-optimization/106594] New: " tnfchris at gcc dot gnu.org
2022-08-12 12:04 ` [Bug tree-optimization/106594] " rguenth at gcc dot gnu.org
2022-08-12 12:44 ` tnfchris at gcc dot gnu.org
2022-08-12 14:01 ` roger at nextmovesoftware dot com
2022-08-12 14:48 ` tnfchris at gcc dot gnu.org
2022-08-12 17:01 ` roger at nextmovesoftware dot com
2022-08-13 11:34 ` [Bug rtl-optimization/106594] " roger at nextmovesoftware dot com
2022-08-14 12:07 ` tnfchris at gcc dot gnu.org
2022-08-17  1:05 ` hp at gcc dot gnu.org
2022-10-19  7:11 ` rguenth at gcc dot gnu.org
2022-10-19  7:52 ` roger at nextmovesoftware dot com
2023-01-17  4:06 ` roger at nextmovesoftware dot com
2023-02-27 10:00 ` tnfchris at gcc dot gnu.org
2023-02-27 10:03 ` ktkachov at gcc dot gnu.org
2023-03-04 22:26 ` segher at gcc dot gnu.org
2023-03-05  8:06 ` roger at nextmovesoftware dot com
2023-03-05 12:00 ` roger at nextmovesoftware dot com
2023-03-05 15:23 ` segher at gcc dot gnu.org [this message]
2023-03-05 19:23 ` tnfchris at gcc dot gnu.org
2023-03-06  7:51 ` rguenth at gcc dot gnu.org
2023-03-06 10:38 ` rsandifo at gcc dot gnu.org
2023-03-06 11:07 ` jakub at gcc dot gnu.org
2023-03-07 11:32 ` roger at nextmovesoftware dot com
2023-03-13  9:30 ` roger at nextmovesoftware dot com
2023-04-17 11:41 ` jakub at gcc dot gnu.org
2023-04-17 12:58 ` jakub at gcc dot gnu.org
2023-04-26  6:56 ` [Bug rtl-optimization/106594] [13/14 " rguenth at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2023-10-30 16:19 ` segher at gcc dot gnu.org
2024-05-21  9:12 ` [Bug rtl-optimization/106594] [13/14/15 " jakub at gcc dot gnu.org

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-106594-4-sa04mFR76q@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).