[PATCH] D12765: [LV] Allow vectorization of loops with induction post-inc expressions
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 02:20:04 PDT 2015
kuhar added a comment.
Hello Michael,
here is complete C code that is being vectorized now and wasn't previously. One could probably reduce it further, but this version preserves the main idea:
#include <stdlib.h>
#define BUFF_SIZE 4096
void __attribute__((noinline))
foo(int y, char *restrict src, char *restrict dest) {
char *p = src;
char *ptr = dest;
int n = (y - 1) < (dest + BUFF_SIZE - ptr - 1)
? (y - 1)
: (dest + BUFF_SIZE - ptr - 1);
for (int vv = 0; vv < n; ++vv)
*ptr++ = *p++;
*ptr++ = *p++;
printf("%d\n", ptr);
}
int main() {
char S[] = "01234567890abcdefghij123456789abcdefghij0123456789XXX";
char D[128] = { 0 };
foo(33, S, D);
printf("%s\n", D);
}
I need this patch to perform some other optimizations (more advanced loop unrolling/vectorizing).
This patch triggers in real-life code. For example, it showed 24.54% improvement in `lnt.MultiSource/Benchmarks/MiBench/automotive-susan/automotive-susan` and 7.60% improvement in `lnt.SingleSource/Benchmarks/BenchmarkGame/recursive` on A57 in aarch64.
Repository:
rL LLVM
http://reviews.llvm.org/D12765
More information about the llvm-commits
mailing list