[PATCH] [LAA] Merge memchecks for accesses separated by a constant offset

silviu.baranga at arm.com silviu.baranga at arm.com
Tue Jun 23 07:02:57 PDT 2015


In http://reviews.llvm.org/D10386#191851, @anemet wrote:

> In http://reviews.llvm.org/D10386#191741, @sbaranga wrote:
>
> > I've looked at this in more detail, and there is a problem with NoDep dependencies since they are not considered to be either forward or backward.  We need to consider these as well, since otherwise we would not cover common cases (and also wouldn't solve the problem for interleaved accesses).
>
>
> Good point but let's see first if we can do this without adding "fake" dependence types for these.  Sounds like we should be able to work this out with using *both* DepCands and InterestingDependences:
>
> If the pointers fall in the same set in DepCands and don't have unknown dependence between then we should be able to add them in the same checking pointer group.  Do you agree?


The problem is that for each checking pointer group we need to get the min/max pointers (otherwise we wouldn't know how to emit memchecks). If we don't have dependencies, then we wouldn't be able to figure out what the bounds are. This might be easier with an example that shows all the issues:

void test(char *in, char * out, int n, int s) {

  for (int i = 0; i < n; ++i)
    out[i] = in[i] + in[i + 1] + in[i + 2] + in[i + 3] + in[i + s];

}

All the accesses to "in" are in the same equivalence class in DepCands, but we get no interesting dependencies (we get only NoDep because there are only reads). If we would say that all these accesses belong to the same pointer checking group, then we would end up having to compare in + s with i and i + 1, etc which we don't know how to do. Since we don't get any dependencies we also don't know how to compare i + 1 with i + 2 etc.

wrt to the pointer checking partitioning algorithm, I think because we need to get the min/max pointers for each group, we can't join two groups when we only see a dependency between them:

Let's say we have 3 pointers, a, b and c and two dependencies for which we can say: a > b and a > c. However we don't know anything about how b and c compare. This can happen when recording too many dependencies, or ScalarEvolution might not return a constant for b - c, or some other condition. If we merge two group checks whenever seeing an edge between them, then we end up with (a, b, c) as a pointer group check. But we don't know what the lower bound of this group is (it's either b or c), so we would end up in some invalid state.

One solution would be to track the min/max elements of each pointer checking group and only add other pointers to it as long as we can keep this property (we know what the min/max pointers are).

Regarding dependencies: maybe it would be somewhat simpler to compare the pointers on the fly (the comparison is simple I think) - and limit the number of iterations that we do when grouping the pointers? Dependencies are closely related to ordering (we need to order pointers when computing dependency types), but different enough to cause problems.

Thanks,
Silviu


http://reviews.llvm.org/D10386

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list