public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110922] New: `(a == b) & (a == c) & (b != c)` is not optimized to false
@ 2023-08-06 17:18 pinskia at gcc dot gnu.org
  2023-08-06 17:21 ` [Bug tree-optimization/110922] " pinskia at gcc dot gnu.org
  2023-08-21  7:46 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-06 17:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110922
           Summary: `(a == b) & (a == c) & (b != c)` is not optimized to
                    false
           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: ---

I noticed this while looking at PR 110919:
```
int f(int a, int b)
{
  _Bool t = a == b;
  _Bool t1 = a == 0;
  _Bool t2 = b != 0;
  return t&t1&t2;
}
```
is not optimized to false.

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

* [Bug tree-optimization/110922] `(a == b) & (a == c) & (b != c)` is not optimized to false
  2023-08-06 17:18 [Bug tree-optimization/110922] New: `(a == b) & (a == c) & (b != c)` is not optimized to false pinskia at gcc dot gnu.org
@ 2023-08-06 17:21 ` pinskia at gcc dot gnu.org
  2023-08-21  7:46 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-06 17:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think you need the following 3 patterns, there might be more though:
(simplify
 (bit_and:c
  (bit_and:c
   (eq:c @0 @1)
   (eq:c @0 @2)
  )
  (ne:c @1 @2)
 )
 ( { falsevalue; } )
)
(simplify
 (bit_and:c
  (bit_and:c
   (eq:c @0 @1)
   (ne:c @1 @2)
  )
  (eq:c @0 @2)
 )
 ( { falsevalue; } )
)
(simplify
 (bit_and:c
  (eq:c @0 @1)
  (bit_and:c
   (ne:c @1 @2)
   (eq:c @0 @2)
  )
 )
 ( { falsevalue; } )
)

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

* [Bug tree-optimization/110922] `(a == b) & (a == c) & (b != c)` is not optimized to false
  2023-08-06 17:18 [Bug tree-optimization/110922] New: `(a == b) & (a == c) & (b != c)` is not optimized to false pinskia at gcc dot gnu.org
  2023-08-06 17:21 ` [Bug tree-optimization/110922] " pinskia at gcc dot gnu.org
@ 2023-08-21  7:46 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-08-21  7:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

end of thread, other threads:[~2023-08-21  7:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-06 17:18 [Bug tree-optimization/110922] New: `(a == b) & (a == c) & (b != c)` is not optimized to false pinskia at gcc dot gnu.org
2023-08-06 17:21 ` [Bug tree-optimization/110922] " pinskia at gcc dot gnu.org
2023-08-21  7:46 ` 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).