public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114999] New: `a - b == b - a` -> `a == b`
@ 2024-05-09  0:11 pinskia at gcc dot gnu.org
  2024-05-09  0:11 ` [Bug tree-optimization/114999] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-09  0:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114999
           Summary: `a - b == b - a` -> `a == b`
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: pinskia at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
int f(int a, int b, int c)
{
        c = a - b;
        int d = -c;
        int t =  c == d;
        int t1 = c == 0;
        return t == t1;
}
```

This is not able to optimize to 1 as we don't detect that `a - b` and `b - a`
are negative of each other.

```
(for cmp (eq ne)
 (simplify
  (cmp:c @0 (negate @0))
```

needs to be improved.

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

end of thread, other threads:[~2024-05-31 21:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-09  0:11 [Bug tree-optimization/114999] New: `a - b == b - a` -> `a == b` pinskia at gcc dot gnu.org
2024-05-09  0:11 ` [Bug tree-optimization/114999] " pinskia at gcc dot gnu.org
2024-05-09  0:16 ` [Bug tree-optimization/114999] A few missing optimizations due to `a - b` and `b - a` not being detected as negatives of each other pinskia at gcc dot gnu.org
2024-05-09  0:17 ` pinskia at gcc dot gnu.org
2024-05-09  0:33 ` pinskia at gcc dot gnu.org
2024-05-09  0:35 ` pinskia at gcc dot gnu.org
2024-05-25  2:55 ` pinskia at gcc dot gnu.org
2024-05-25  5:42 ` pinskia at gcc dot gnu.org
2024-05-31 21:29 ` pinskia at gcc dot gnu.org
2024-05-31 21: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).