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/113186] New: [13/14 Regression] `(a^c) & (a^!c)` is not optimized to 0 for bool
Date: Sun, 31 Dec 2023 21:07:06 +0000	[thread overview]
Message-ID: <bug-113186-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113186
           Summary: [13/14 Regression] `(a^c) & (a^!c)` is not optimized
                    to 0 for bool
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
bool f(bool a, bool c)
{
  bool b = (a^c);
  bool d = (a^!c);
  return b & d;
}
```
This should optimize to 0 but does not since GCC 13. With the C++ front-end, I
suspect since r13-1779-g375668e0508fbe . With the C front-end, it started on
the trunk.

For C have in forwprop1:
  b_7 = a_5(D) ^ c_6(D);
  _11 = a_5(D) ^ c_6(D);
  _12 = a_5(D) == c_6(D);
  _13 = b_7 & _12;

For C++ we have (at -O1):
  b_7 = a_5(D) != c_6(D);
  _1 = ~c_6(D);
  d_8 = _1 != a_5(D);
  _11 = b_7 & d_8;

For C++ at -O2 in forwprop2, we have similar as what with the C front-end.

             reply	other threads:[~2023-12-31 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-31 21:07 pinskia at gcc dot gnu.org [this message]
2023-12-31 21:07 ` [Bug tree-optimization/113186] " pinskia at gcc dot gnu.org
2023-12-31 21:15 ` pinskia at gcc dot gnu.org
2024-01-01  0:49 ` pinskia at gcc dot gnu.org
2024-01-01  4:04 ` pinskia at gcc dot gnu.org
2024-01-04 20:52 ` cvs-commit at gcc dot gnu.org
2024-01-04 20:52 ` 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-113186-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).