public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0
@ 2021-11-22 11:06 pinskia at gcc dot gnu.org
  2021-11-22 11:06 ` [Bug tree-optimization/103356] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-22 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103356
           Summary: bool0 == ~bool1 should simplify to bool1 ^ bool0
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
bool f(bool a, bool b)
{
  b = !b;
  return a==b;
}

---- CUT ---
LLVM produces:
        mov     eax, edi
        xor     eax, esi
        ret

While GCC produces:
        xor     esi, 1
        cmp     sil, dil
        sete    al
        ret

GCC should be able to produce the xor case.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103356] bool0 == ~bool1 should simplify to bool1 ^ bool0
  2021-11-22 11:06 [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0 pinskia at gcc dot gnu.org
@ 2021-11-22 11:06 ` pinskia at gcc dot gnu.org
  2022-11-26 16:47 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-22 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-11-22

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103356] bool0 == ~bool1 should simplify to bool1 ^ bool0
  2021-11-22 11:06 [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0 pinskia at gcc dot gnu.org
  2021-11-22 11:06 ` [Bug tree-optimization/103356] " pinskia at gcc dot gnu.org
@ 2022-11-26 16:47 ` pinskia at gcc dot gnu.org
  2022-11-26 18:01 ` cvs-commit at gcc dot gnu.org
  2022-11-26 18:01 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-26 16:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note for:

bool f(bool a, bool b)
{
  b = !b;
  return a!=b;
}
We do the correct thing since r13-1779-g375668e0508fbe.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103356] bool0 == ~bool1 should simplify to bool1 ^ bool0
  2021-11-22 11:06 [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0 pinskia at gcc dot gnu.org
  2021-11-22 11:06 ` [Bug tree-optimization/103356] " pinskia at gcc dot gnu.org
  2022-11-26 16:47 ` pinskia at gcc dot gnu.org
@ 2022-11-26 18:01 ` cvs-commit at gcc dot gnu.org
  2022-11-26 18:01 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-26 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pinskia@gcc.gnu.org>:

https://gcc.gnu.org/g:f9378e3cc390f9bcc310ce206c6773a817aff2ca

commit r13-4311-gf9378e3cc390f9bcc310ce206c6773a817aff2ca
Author: Andrew Pinski <apinski@marvell.com>
Date:   Sat Nov 26 07:37:40 2022 +0000

    tree-optimization/103356 Add missing (~a) == b folding for _Bool

    The following makes sure to fold (~a) ==  b to a ^ b for truth
    values.

    OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

    Thanks,
    Andrew Pinski

            PR tree-optimization/103356

    gcc/ChangeLog:

            * match.pd: ((~a) == b -> a ^ b): New pattern.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr103356-1.c: New test.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug tree-optimization/103356] bool0 == ~bool1 should simplify to bool1 ^ bool0
  2021-11-22 11:06 [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-11-26 18:01 ` cvs-commit at gcc dot gnu.org
@ 2022-11-26 18:01 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-26 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |13.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-26 18:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 11:06 [Bug tree-optimization/103356] New: bool0 == ~bool1 should simplify to bool1 ^ bool0 pinskia at gcc dot gnu.org
2021-11-22 11:06 ` [Bug tree-optimization/103356] " pinskia at gcc dot gnu.org
2022-11-26 16:47 ` pinskia at gcc dot gnu.org
2022-11-26 18:01 ` cvs-commit at gcc dot gnu.org
2022-11-26 18:01 ` pinskia at gcc dot gnu.org

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).