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 c/109393] Very trivial address calculation does not fold
Date: Thu, 11 May 2023 12:59:46 +0000	[thread overview]
Message-ID: <bug-109393-4-1Gfdbz0evc@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109393-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from manolis.tsamis at vrull dot eu ---
(In reply to Richard Biener from comment #5)
> (In reply to manolis.tsamis from comment #4)
> > Given the original transform it should be valid to propagate the constant
> > addition through the cast?
> 
> Yes.  Note doing so loses information, we know i + 1 doesn't overflow
> (undefined behavior).  Widening preserves this knowledge I think, but if
> just an unsigned conversion would be propagated it would be lost.

So, is that the reason that this transform isn't already implemented as an
optimisation?

But then again isn't this information also lost in the code currently produced
by GCC, where the constant is already propagated? Although I can see how it is
different to do the propagation of constants in the front-end only vs doing it
anywhere while transforming the code; maybe that's the difference that matters.
But hopefully doing better canonicalization/constant folding on address
calculations and constants should also result in better optimisation
opportunities overall.

  parent reply	other threads:[~2023-05-11 12:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 17:57 [Bug tree-optimization/109393] New: " manolis.tsamis at vrull dot eu
2023-04-03 18:07 ` [Bug tree-optimization/109393] " pinskia at gcc dot gnu.org
2023-04-04 12:12 ` manolis.tsamis at vrull dot eu
2023-04-11 12:16 ` [Bug c/109393] " rguenth at gcc dot gnu.org
2023-05-10 12:55 ` manolis.tsamis at vrull dot eu
2023-05-11 12:47 ` rguenth at gcc dot gnu.org
2023-05-11 12:59 ` manolis.tsamis at vrull dot eu [this message]
2023-09-04 11:38 ` manolis.tsamis at vrull dot eu
2023-09-04 13:06 ` philipp.tomsich at vrull dot eu
2023-09-08 13:14 ` 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-109393-4-1Gfdbz0evc@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).