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 tree-optimization/103168] Value numbering for PRE of pure functions can be improved
Date: Mon, 22 Nov 2021 12:54:44 +0000	[thread overview]
Message-ID: <bug-103168-4-wtav3PZMeQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103168-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
            Summary|[9/10/11/12 Regression]     |Value numbering for PRE of
                   |Value numbering for PRE of  |pure functions can be
                   |pure functions can be       |improved
                   |improved                    |

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #7)
> The testcase in comment #3 is optimized by GCC 6 but not by GCC 7 up.

That's beacause GCC 6 detected a::ret () as const while with GCC 7 and up it's
only pure.

;; Function a::ret (_ZN1a3retEi, funcdef_no=0, decl_uid=2371, cgraph_uid=1,
symbol_order=0)

 neither


 local analysis of static int a::ret(int)/0
   scanning: return v_1(D);
    checking previously known:
static int a::ret(int)/0 is not a malloc candidate, reason: Return value is not
SSA_NAME or not a pointer type.
Function is locally const.
Function found to be const: static int a::ret(int)/0
Dropping state to PURE because function does not bind to current def.
Declaration updated to be const: static int a::ret(int)/0
__attribute__((noinline))
int a::ret (int v)
{
  <bb 2> [local count: 1073741824]:
  return v_1(D);

}

the comment in the code says

  /* Consider function:

     bool a(int *p)
     { 
       return *p==*p;
     }

     During early optimization we will turn this into:

     bool a(int *p)
     { 
       return true;
     }

     Now if this function will be detected as CONST however when interposed it
     may end up being just pure.  We always must assume the worst scenario
here.
   */

so indeed that's an issue.  So it's a bug fixed, not an optimization
regression.

  parent reply	other threads:[~2021-11-22 12:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10 11:15 [Bug tree-optimization/103168] New: Value numbering " hubicka at gcc dot gnu.org
2021-11-10 11:16 ` [Bug tree-optimization/103168] " hubicka at gcc dot gnu.org
2021-11-11  9:12 ` [Bug tree-optimization/103168] Value numbering for PRE " rguenth at gcc dot gnu.org
2021-11-17 20:28 ` hubicka at gcc dot gnu.org
2021-11-18  9:13 ` rguenth at gcc dot gnu.org
2021-11-18  9:39 ` hubicka at kam dot mff.cuni.cz
2021-11-18  9:40 ` hubicka at kam dot mff.cuni.cz
2021-11-19 14:21 ` [Bug tree-optimization/103168] [9/10/11/12 Regression] " hubicka at gcc dot gnu.org
2021-11-22 12:54 ` rguenth at gcc dot gnu.org [this message]
2021-11-22 13:07 ` [Bug tree-optimization/103168] " hubicka at kam dot mff.cuni.cz
2021-11-22 14:19 ` rguenth at gcc dot gnu.org
2021-11-22 14:24 ` rguenth at gcc dot gnu.org
2021-11-22 15:14 ` hubicka at kam dot mff.cuni.cz
2021-11-22 23:07 ` hubicka at gcc dot gnu.org
2021-11-23  0:26   ` Jan Hubicka
2021-11-23  7:26   ` Jan Hubicka
2021-11-23  0:26 ` hubicka at kam dot mff.cuni.cz
2021-11-23  7:26 ` hubicka at kam dot mff.cuni.cz
2021-11-23  7:43 ` rguenth at gcc dot gnu.org
2021-11-23  7:49 ` hubicka at gcc dot gnu.org
2021-11-24 11:40 ` cvs-commit at gcc dot gnu.org
2021-11-24 12:06 ` rguenth 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-103168-4-wtav3PZMeQ@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).