[Inliner] Preserve llvm.mem.parallel_loop_access metadata
authorHal Finkel <hfinkel@anl.gov>
Thu, 28 Apr 2016 23:00:04 +0000 (23:00 +0000)
committerHal Finkel <hfinkel@anl.gov>
Thu, 28 Apr 2016 23:00:04 +0000 (23:00 +0000)
commit50316d95a935161b8626e637dbc29f14bc813b77
tree7709f674664ccf3332824a1589e45eebf7ad0a1a
parent70e70e6eb93cf8e99d4284326c520463f2b880d1
[Inliner] Preserve llvm.mem.parallel_loop_access metadata

When inlining a call site with llvm.mem.parallel_loop_access metadata, this
metadata needs to be propagated to all cloned memory-accessing instructions.
Otherwise, inlining parts of the loop body will invalidate the annotation.

With this functionality, we now vectorize the following as expected:

  void Body(int *res, int *c, int *d, int *p, int i) {
    res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
  }

  void Test(int *res, int *c, int *d, int *p, int n) {
    int i;

  #pragma clang loop vectorize(assume_safety)
    for (i = 0; i < 1600; i++) {
      Body(res, c, d, p, i);
    }
  }

llvm-svn: 267949
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/Transforms/Inline/parallel-loop-md.ll [new file with mode: 0644]