[PATCH] D9375: An llvm.noalias intrinsic

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 18:08:41 PDT 2016


hfinkel added a comment.

In https://reviews.llvm.org/D9375#481339, @dberlin wrote:

> So, the summary says:
>
> Also, on the data dependence, while poses obvious difficulties on the optimizer (and may of the patches are to address this), a strict control dependence is not sufficient (so we can't make it more like the lifetime intrinsics which take a pointer argument). Specifically, we need to be able to represent this kind of construct:
>  "void foo(T * restrict x, T * restrict y) {
>
>   for (int i = 0; i < 1600; ++i)
>     x[2*i+1] = y[2*i] + 1;
>
> }"
>
> Is this summary still correct?
>  If so, i want to understand this.  I don't want to make you do the work, i just want to understand what the issue is.


Certainly. The summary says:

> Also, on the data dependence, while poses obvious difficulties on the optimizer (and may of the patches are to address this), a strict control dependence is not sufficient (so we can't make it more like the lifetime intrinsics which take a pointer argument). > Specifically, we need to be able to represent this kind of construct:

> 

>   void foo(T * restrict x, T * restrict y) {

>     for (int i = 0; i < 1600; ++i)

>       x[2*i+1] = y[2*i] + 1;

>   }

> 

> when inlined from the call foo(q, q).


and you didn't quote that last line, so I wonder if you missed it. So the problem here is that, if we have foo(q,q), and I had some intrinsic that only had a control dependence, like our current @llvm.noalias but without the return value, then we'd end up with:

  call @llvm.noalias(%q, !scope)
  call @llvm.noalias(%q, !scope)
  %p1 = gep %q, ... (2*i)
  %p2 = gep %q, ... (2*i+1)
  %v = load %p1, !scope
  store %v, %p2, !scope

In this example the indexing is simple and we'd get the (lack of) aliasing anyway, but in the general case the problem is that we lose which pointer values are derived from one restrict pointer and which are derived from the other once we inline. That's why I have @llvm.noalias return a value.


https://reviews.llvm.org/D9375





More information about the llvm-commits mailing list