[PATCH] D68994: [RFC] Redefine `convergent` in terms of dynamic instances

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 08:09:00 PDT 2019


nhaehnle marked an inline comment as done.
nhaehnle added a comment.

In D68994#1709802 <https://reviews.llvm.org/D68994#1709802>, @arsenm wrote:

> Are you planning on adding codegen support in a separate patch?


Yes, though it'll be a while before it's ready.



================
Comment at: llvm/docs/DynamicInstances.rst:229
+
+  void @llvm.convergence.point(token %anchor) convergent readnone
+
----------------
arsenm wrote:
> I don't fully understand what the 'point' of this one is. What is the point of ensuring nonreconvergence? Which real example does this correspond to?
It allows us to mark regions of code that are semantically part of a loop for the purposes of convergence even when they're not part of the loop as far as loop analysis is concerned. This applies to high-level code such as the following:
```
int divergent_key = ...;
int v = ...;
int sum;
for (;;;) {
  tok = @llvm.convergence.anchor()
  int uniform_key = readfirstlane(divergent_key);
  if (uniform_key == divergent_key) {
    sum = subgroup_reduce_add(v);
    @llvm.convergence.point(tok)
    break;
  }
}
```
The point indicates that no reconvergence should happen for the execution of the reduce operation (or in a sense, that the reduce operation should not be moved out of the loop).

Points are in some sense redundant, as the code above could be equivalently rewritten as:
```
int divergent_key = ...;
int v = ...;
int sum;
for (;;;) {
  tok = @llvm.convergence.anchor()
  int uniform_key = readfirstlane(divergent_key);
  if (uniform_key == divergent_key) {
    sum = subgroup_reduce_add(v);
  }
  @llvm.convergence.join(tok)
  if (uniform_key == divergent_key)
    break;
}
```
Though that reformulation loses some information about control-flow, in particular it leads to more conservative live ranges.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68994/new/

https://reviews.llvm.org/D68994





More information about the llvm-commits mailing list