[llvm] [InstCombine] Optimize AMDGPU ballot + assume uniformity patterns (PR #160670)
Teja Alaghari via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 05:21:47 PDT 2025
TejaX-Alaghari wrote:
Hey @arsenm,
Thanks for your quick response :)
The current PR description doesn't make justice to the problem that's being solved! which has caused a lot of confusion (my bad). I'll mark the PR as a draft until the implementation details are ironed out!
Let me re-iterate the problem statement and the approach I'm aiming for, in my view -
Per Uniformity Analysis (UA), `%cmp` value is considered divergent in the example kernel above. But `llvm.assume` flips that assumption if we follow backwards through the use-def chain (`%uniform` -> `%ballot` -> `%cmp`)
> I don't understand why this is being folded in the context of the assume argument.
The presence of `llvm.assume` line makes us safely infer that `%uniform`, `%ballot` & `%cmp` are uniform. Which is why, the implementation is designed to fold relying on `llvm.assume`.
> I attempted to make use of this in https://reviews.llvm.org/D137142, but it was never completed. Did that get separately implemented?
I'm not sure whether it got implemented. I've made that statement per my own personal understanding as that made sense to me.
> Also, I would expect the assume to inform uniformity analysis, not just be dropped here
Currently, there is a limitation with the UA that it cannot propagate the assumptions backward (like uniform -> ballot -> cmp). So, this implementation is trying to play the role of a temporary patch which can be removed when this functionality is implemented in the UA.
https://github.com/llvm/llvm-project/pull/160670
More information about the llvm-commits
mailing list