public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59739] missed optimization: attribute ((pure)) with aggregate returns
Date: Fri, 20 Mar 2015 10:58:00 -0000	[thread overview]
Message-ID: <bug-59739-4-1r8NZuAiEG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-59739-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|NEW                         |ASSIGNED
                 CC|rguenther at suse dot de           |
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
            Summary|missed optimization:        |missed optimization:
                   |attribute ((pure)) could be |attribute ((pure)) with
                   |honored more often          |aggregate returns

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is rather that value-numbering is SSA based and thus

  D.2954 = globalStruct ();
  _10 = D.2954.val;
  D.2955 = globalStruct ();
  _12 = D.2955.val;

to CSE _12 to _10 we lookup the D.2955.val load and arrive at its def
D.2955 = globalStruct (); from where we can't look further.  FRE
has some tricks to look through aggregate copies but in this case
the aggregate copy source is a function call...

What we'd really need here is to re-write those aggregate temporaries
into SSA form (that also get's us aggregate copyprop for free).  We
can't have partial defs for those, of course, and we'd have to be careful
to not create overlapping life-ranges (because of cost issues - out-of-SSA
will make those "registers" memory again).

Eventually we could do this re-write into SSA form just for SCCVN ...

I don't see how we can easily extend the aggregate copy trick to cover
function calls.

Mine for now.  C testcase:

extern void link_error (void);

struct X { int i; };

struct X foo (void) __attribute__((pure));

int main()
{
  if (foo ().i != foo ().i)
    link_error ();
  return 0;
}


  parent reply	other threads:[~2015-03-20 10:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-09 16:43 [Bug c++/59739] New: missed optimization: attribute ((pure)) could be honored more often joerg.richter@pdv-fs.de
2014-01-15 16:16 ` [Bug c++/59739] " joerg.richter@pdv-fs.de
2015-03-19  9:19 ` paolo.carlini at oracle dot com
2015-03-19 22:11 ` hubicka at gcc dot gnu.org
2015-03-20 10:58 ` rguenth at gcc dot gnu.org [this message]
2021-12-20 20:28 ` [Bug c++/59739] missed optimization: attribute ((pure)) with aggregate returns pinskia at gcc dot gnu.org
2024-04-09  7:06 ` pinskia at gcc dot gnu.org
2024-04-09  7:07 ` pinskia 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-59739-4-1r8NZuAiEG@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).