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

            Bug ID: 108017
           Summary: ptr+v >= ptr + d should converted into (long)v >=
                    CST(/sizeof(*ptr))
           Product: gcc
           Version: 13.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:
```
_Bool f(int *a, __SIZE_TYPE__ t, __SIZE_TYPE__ t1)
{
    int *b = a + t;
    int *c = a + t1;
    return c >= b;
}

_Bool f1(int *a, __SIZE_TYPE__ t, __SIZE_TYPE__ t1)
{
    long tt = t;
    long tt1 = t1;
    return tt1 >= tt;
}
```
These two should give the same code.

LLVM does this optimization.

I noticed this while looking into the code from the blog at
https://lemire.me/blog/2022/12/06/optimizing-compilers-reload-vector-constants-needlessly/
(but not vector constant issue though).

Reply via email to