public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/113379] New: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b`
@ 2024-01-13 16:53 pinskia at gcc dot gnu.org
  2024-01-13 16:58 ` [Bug tree-optimization/113379] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-13 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113379
           Summary: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b`
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
int f(int a, int b)
{
        int c = a > b ? a : b;
        int d = a < b ? a : b;
        return c == d;
}
```

This should be optimized to `a == b;`

Likewise for the `!=` case too.

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

* [Bug tree-optimization/113379] `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b`
  2024-01-13 16:53 [Bug tree-optimization/113379] New: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b` pinskia at gcc dot gnu.org
@ 2024-01-13 16:58 ` pinskia at gcc dot gnu.org
  2024-01-15  8:36 ` rguenth at gcc dot gnu.org
  2024-01-15 16:44 ` jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-13 16:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The rest of the comparison operators:

`MIN <a, b> <= MAX <a, b>` should be simplified down to true.
`MIN <a, b> > MAX <a, b>` should be simplified down to false.

`MIN <a, b> < MAX <a, b>` should be simplified down to `a != b`
`MIN <a, b> >= MAX <a, b>` should be simplified down to `a == b`

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

* [Bug tree-optimization/113379] `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b`
  2024-01-13 16:53 [Bug tree-optimization/113379] New: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b` pinskia at gcc dot gnu.org
  2024-01-13 16:58 ` [Bug tree-optimization/113379] " pinskia at gcc dot gnu.org
@ 2024-01-15  8:36 ` rguenth at gcc dot gnu.org
  2024-01-15 16:44 ` jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-15  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-01-15
     Ever confirmed|0                           |1

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

* [Bug tree-optimization/113379] `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b`
  2024-01-13 16:53 [Bug tree-optimization/113379] New: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b` pinskia at gcc dot gnu.org
  2024-01-13 16:58 ` [Bug tree-optimization/113379] " pinskia at gcc dot gnu.org
  2024-01-15  8:36 ` rguenth at gcc dot gnu.org
@ 2024-01-15 16:44 ` jsm28 at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2024-01-15 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Note that some of these aren't valid for floating point in the presence of
NaNs.

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

end of thread, other threads:[~2024-01-15 16:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-13 16:53 [Bug tree-optimization/113379] New: `MIN<a,b> == MAX<a,b>` should be optimzed to `a == b` pinskia at gcc dot gnu.org
2024-01-13 16:58 ` [Bug tree-optimization/113379] " pinskia at gcc dot gnu.org
2024-01-15  8:36 ` rguenth at gcc dot gnu.org
2024-01-15 16:44 ` jsm28 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).