public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
@ 2023-08-07 16:52 pinskia at gcc dot gnu.org
  2023-08-07 17:20 ` [Bug tree-optimization/110937] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 16:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110937
           Summary: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^
                    bool1
           Product: gcc
           Version: 14.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 f2(_Bool a, _Bool b)
{
        if (a)
          return !b;
        return b;
}
```
This should be optimized to just:
```
_Bool f2_(_Bool a, _Bool b)
{
  return a ^ b;
}
```

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

* [Bug tree-optimization/110937] (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
  2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
@ 2023-08-07 17:20 ` pinskia at gcc dot gnu.org
  2023-08-07 18:31 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2023-08-07
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org

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

* [Bug tree-optimization/110937] (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
  2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
  2023-08-07 17:20 ` [Bug tree-optimization/110937] " pinskia at gcc dot gnu.org
@ 2023-08-07 18:31 ` pinskia at gcc dot gnu.org
  2023-08-07 18:35 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 18:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 55702
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55702&action=edit
Patch which I am testing

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

* [Bug tree-optimization/110937] (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
  2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
  2023-08-07 17:20 ` [Bug tree-optimization/110937] " pinskia at gcc dot gnu.org
  2023-08-07 18:31 ` pinskia at gcc dot gnu.org
@ 2023-08-07 18:35 ` pinskia at gcc dot gnu.org
  2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org
  2023-08-09 19:27 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-07 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Created attachment 55702 [details]
> Patch which I am testing

Actually I am going to fix this with PR 100798.

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

* [Bug tree-optimization/110937] (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
  2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-08-07 18:35 ` pinskia at gcc dot gnu.org
@ 2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org
  2023-08-09 19:27 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-08-09 19:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:7fb65f102851248bafa0815401d8bdcea6d7626c

commit r14-3110-g7fb65f102851248bafa0815401d8bdcea6d7626c
Author: Andrew Pinski <apinski@marvell.com>
Date:   Mon Aug 7 10:47:09 2023 -0700

    MATCH: [PR110937/PR100798] (a ? ~b : b) should be optimized to b ^ -(a)

    This adds a simple match pattern for this case.
    I noticed it a couple of different places.
    One while I was looking at code generation of a parser and
    also while I was looking at locations where bitwise_inverted_equal_p
    should be used more.

    Committed as approved after bootstrapped and tested on x86_64-linux-gnu
with no regressions.

            PR tree-optimization/110937
            PR tree-optimization/100798

    gcc/ChangeLog:

            * match.pd (`a ? ~b : b`): Handle this
            case.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/bool-14.c: New test.
            * gcc.dg/tree-ssa/bool-15.c: New test.
            * gcc.dg/tree-ssa/phi-opt-33.c: New test.
            * gcc.dg/tree-ssa/20030709-2.c: Update testcase
            so `a ? -1 : 0` is not used to hit the match
            pattern.

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

* [Bug tree-optimization/110937] (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1
  2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org
@ 2023-08-09 19:27 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-09 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-08-09 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 16:52 [Bug tree-optimization/110937] New: (bool0 ? bool1^1 : bool1) is not optimized to bool0 ^ bool1 pinskia at gcc dot gnu.org
2023-08-07 17:20 ` [Bug tree-optimization/110937] " pinskia at gcc dot gnu.org
2023-08-07 18:31 ` pinskia at gcc dot gnu.org
2023-08-07 18:35 ` pinskia at gcc dot gnu.org
2023-08-09 19:22 ` cvs-commit at gcc dot gnu.org
2023-08-09 19:27 ` 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).