Do anyone know how to get LLVM’s vectorizer to work on this code?
struct pair {
int x[4], y[4];
};
void foo(int n, struct pair *a, int *restrict rx, int *restrict ry) {
int x = 0, y = 0;
for (int i = 0; i < n; i++) {
x += (a+(i/4))->x[i%4];
y += (a+(i/4))->y[i%4];
}
*rx = x;
*ry = y;
}
I have a pass that converts structures such as {int, int} into {int x 4, int x 4}, but the transformation is profitable if it can work with the vectorizer.