Skip to content

[clang] Unable to vectorize loop with connectivity table on result index #115595

@bemichel

Description

@bemichel

Hi,

I try to find if there is already an issue on the subject, but I did not find any.

I work on loop like this (https://godbolt.org/z/fchd4e54e), where the final index on the result array y is given by the integer table face_cell :

void compute_local_extrema(
  const int                nface, 
  const int                ncell, 
  const int*    __restrict face_cell,
  const double* __restrict x, 
        double* __restrict y) {
  int il, ir;

#pragma clang loop distribute(enable) vectorize(enable) interleave(enable)
  for (int iface=0; iface<nface; ++iface) {
    il = face_cell[iface];
    ir = face_cell[iface+nface];
    y[il] = std::max(y[il], x[ir]);
  }
}

It seems that the auto-vectorize does not work on the kind of loop, despite the fact that it seems working on GCC (https://godbolt.org/z/944q8M6T1 from 12.2 to 13.3).

Is there a way to finally vectorize this kind of loop ?
If it is possible, can you give me some advices on how to do this?

Thanks a lot for your help.

Bertrand M.

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions