public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102872] New: If statement is always false but not figured out at gimple level
Date: Thu, 21 Oct 2021 08:25:31 +0000	[thread overview]
Message-ID: <bug-102872-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 102872
           Summary: If statement is always false but not figured out at
                    gimple level
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, TREE
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
void foo(void);

static int a, b;
int main() {
  for (; a; ++a) {
    unsigned short d = a;
    if (!(b | d) && d)
      foo();
  }
}
---- CUT ---
This is the reduced testcase of PR 102703 but without the store to a static
variable which then was removed.

In VRP1 we have:
  d_10 = (short unsigned int) a.3_5;
  _9 = a.3_5 & 65535;
  if (_9 == 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 6>; [50.00%]

  <bb 4> [local count: 477815112]:
  if (d_10 != 0)
    goto <bb 5>; [33.00%]
  else
    goto <bb 6>; [67.00%]

  <bb 5> [local count: 157678986]:
  foo ();

_9 and d_10 have the same value though different types.

             reply	other threads:[~2021-10-21  8:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21  8:25 pinskia at gcc dot gnu.org [this message]
2021-10-21  8:28 ` [Bug tree-optimization/102872] " pinskia at gcc dot gnu.org
2021-10-21  8:58 ` rguenth at gcc dot gnu.org
2021-11-20  8:59 ` pinskia at gcc dot gnu.org
2021-11-22 11:17 ` rguenth at gcc dot gnu.org
2022-10-13 15:29 ` cvs-commit at gcc dot gnu.org
2022-10-13 17:02 ` amacleod at redhat dot com
2022-11-28 22:41 ` 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-102872-4@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).