public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107881] New: (a <= b) == (b >= a) should be optimized to (a == b)
@ 2022-11-26 18:18 pinskia at gcc dot gnu.org
  2022-11-26 18:20 ` [Bug tree-optimization/107881] " pinskia at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-26 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107881
           Summary: (a <= b) == (b >= a) should be optimized to (a == b)
           Product: gcc
           Version: 13.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
            Blocks: 107880
  Target Milestone: ---

Take:
```
bool f(int a, int b)
{
  bool t = b <= a;
  bool t1 = a <= b;
  return t == t1;
}
```

We should optimize this to just:
```
bool f1(int a, int b)
{
  return a == b;
}
```
LLVM is able to do it.
We can optimize for & and | but not ^ or ==. (note != gets changed into ^)


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107880
[Bug 107880] bool tautology missed optimisation

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

end of thread, other threads:[~2023-09-12 15:03 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-26 18:18 [Bug tree-optimization/107881] New: (a <= b) == (b >= a) should be optimized to (a == b) pinskia at gcc dot gnu.org
2022-11-26 18:20 ` [Bug tree-optimization/107881] " pinskia at gcc dot gnu.org
2022-11-26 19:51 ` pinskia at gcc dot gnu.org
2022-11-26 19:56 ` pinskia at gcc dot gnu.org
2022-11-26 19:57 ` pinskia at gcc dot gnu.org
2022-11-26 20:26 ` pinskia at gcc dot gnu.org
2022-11-28  2:22 ` pinskia at gcc dot gnu.org
2022-11-28  2:33 ` pinskia at gcc dot gnu.org
2022-11-28  2:50 ` pinskia at gcc dot gnu.org
2023-01-19 15:00 ` pinskia at gcc dot gnu.org
2023-08-28 20:35 ` pinskia at gcc dot gnu.org
2023-08-28 20:36 ` pinskia at gcc dot gnu.org
2023-08-28 21:30 ` pinskia at gcc dot gnu.org
2023-08-28 21:31 ` pinskia at gcc dot gnu.org
2023-08-29  4:07 ` pinskia at gcc dot gnu.org
2023-09-11 21:45 ` pinskia at gcc dot gnu.org
2023-09-12  4:23 ` pinskia at gcc dot gnu.org
2023-09-12 15:02 ` cvs-commit at gcc dot gnu.org
2023-09-12 15:03 ` 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).