[PATCH] D153414: [LLVM] Do not speculate convergent calls

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 02:25:39 PDT 2023


sameerds added a comment.

In D153414#4437705 <https://reviews.llvm.org/D153414#4437705>, @nikic wrote:

> In D153414#4437698 <https://reviews.llvm.org/D153414#4437698>, @arsenm wrote:
>
>> It depends. In the future we could contextually speculate convergent instructions (e.g. if the conditions reaching the point are uniform)
>
> I still think that would not allow you to put `speculatable` on the function. A speculatable function has to be speculatable //unconditionally//. Absense of the speculatable attribute does not imply that the call cannot be speculated, just that we don't know that it is //always// safe to speculate.

>From a single-threaded point of view, a speculatable function is speculatable unconditionally, because the attribute is only reporting that certain side-effects will not happen. But whether it can be speculated across a divergent branch is decided by whether it is marked convergent. These two things are orthogonal. If a pass wants to speculate a convergent function across a uniform branch (or later even across a divergent branch if permitted by convergence tokesn), then this check for `isConvergent` will be combined by additional information passed from outside to `isSafeToSpeculativelyExecute()`.

Theoretically, it is plausible that some function may be non-convergent and speculatable, but based on the environment (e.g., HIP or Vulcan or OpenCL), a call to such a function may be convergent. I don't actually have an example of such a thing right now, though it was considered at one point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153414



More information about the llvm-commits mailing list