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.

Reply via email to