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

            Bug ID: 112742
           Summary: missed vectorization with src[a*b+i] where a*b is not
                    int rather than same percission as size_type
           Product: gcc
           Version: 14.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: 53947
  Target Milestone: ---
            Target: x86_64-*-* aarch64-*-*

Take:
```
void f(unsigned char * __restrict src, 
      unsigned stride, int h, int row)
{
  unsigned char *src1 = src+row*stride;
  for(int col = 0; col < h; col++)
    {
        src1[col]=src1[col] + 1;
    }
}

void f1(unsigned char * __restrict src, unsigned rs,
      unsigned cs, unsigned stride, int h, int row)
{
  for(int col = 0; col < h; col++)
    {
        src[row*stride+col]=src[row*stride+col] + 1;
    }
}
```

These 2 function should be vectorized. But f1 does not. If we use -m32 (or
-mabi=ilp32 on aarch64) f1 does now get vectorized.
Note LLVM is able to vectorize f1 for both aarch64 and x86_64.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

Reply via email to