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/101991] bit_and or bit_ior with an invariant inside loop is not pulled out of the loop
Date: Fri, 20 Aug 2021 08:45:48 +0000	[thread overview]
Message-ID: <bug-101991-4-UwFL9Itora@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101991-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-20

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
  <bb 3> [local count: 955630225]:
  # r_11 = PHI <r_8(6), d_3(D)(5)>
  r_8 = e_7(D) & r_11;

I wonder if this is sth for phiopt to pattern match.  In principle VN
would need to figure (for PRE) that the PHI translated d_3(D) & e_7(D)
is equal to r_8.  So the "trick" (aka pattern-matching) could be done
during phi_translation.

But then both look like a hack.  Curiously when we do

int f(int t, int d, int e)
{
  int r = d & e;
  for(int i = 0; i < t; i++)
    r &= e;
  return r;
}

aka "peel" one iteration, then CCP is what eliminates the in-loop AND.
Ah, that's because we simplify d & e & e since we optimistically start
with just the entry edge value.  And that remains so.  With PRE
we're not fully re-doing VN of PHIs but phi-translation seeks to
re-use existing value-numbers where possible, so a programmatic approach
doesn't work here.

  reply	other threads:[~2021-08-20  8:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20  2:35 [Bug tree-optimization/101991] New: " pinskia at gcc dot gnu.org
2021-08-20  8:45 ` rguenth at gcc dot gnu.org [this message]
2022-05-26  8:29 ` [Bug tree-optimization/101991] " pinskia at gcc dot gnu.org
2022-09-22  2:06 ` lingling.kong7 at gmail dot com
2022-10-22 22:30 ` 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-101991-4-UwFL9Itora@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).