[PATCH] D85604: SimplifyCFG: prevent certain transforms on convergent operations
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 07:59:49 PDT 2020
nhaehnle added inline comments.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4474
+ if (CI->isConvergent())
+ return false;
+
----------------
efriedma wrote:
> I can't imagine a function that makes sense to mark both convergent and speculatable.
An example would be a `shuffle` operation:
```
if (cond1) {
y = shuffle(x, srcIdx, token);
foo(y);
} else if (cond2) {
y = shuffle(x, srcIdx, token);
bar(y)
}
```
If `any(cond1 || cond2)` is sufficiently likely, the following is more efficient:
```
y = shuffle(x, srcIdx, token);
if (cond1) {
foo(y);
} else if (cond2) {
bar(y)
}
```
This transform is correct for the underlying hardware implementation if `srcIdx` can be out-of-range without causing undefined behavior.
`convergent speculatable` would still indicate that the transform is forbidden, because it changes the set of communicating threads, but I think we're going to want attributes that partially relax `convergent` again. In this case, we'd allow changing the set of communicating threads to a superset.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85604/new/
https://reviews.llvm.org/D85604
More information about the llvm-commits
mailing list