[llvm] [AMDGPU][TTI] Add Target Hook for Instruction Uniformity (getInstructionUniformity) (PR #137639)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 24 07:34:12 PDT 2025
jayfoad wrote:
> This patch introduces a new target hook `isSpecialUniformIntrinsic()` in `TargetTransformInfo`, enabling targets to describe more complex relationships between operand uniformity and instruction uniformity.
>
> Currently, all the users of the divergent values are marked as divergent conservatively; instead target can override the hook `isSpecialUniformIntrinsic()` to capture the operand-dependent uniformity.
The way you have implemented this, `isSpecialUniformIntrinsic` just identifies intrinsics that have yet another fixed way of calculating their uniformity: they are uniform if _any_ of their operands are uniform. This is useful for some basic permute-style operations but really not flexible enough to be more generally useful.
For example, llvm.amdgcn.permlane16 has extra `fetch_invalid` and `bound_control` operands, so the "result if uniform if any operand is uniform" rule does not work for it! It needs to be something like "result is uniform is either of the first two operands are uniform (possibly with some more special cases depending on the values of the extra operands)".
I really think we need a more flexible target hook that can implement any arbitrary logic for the uniformity of the result of an operation, based on the uniformity of each of its operands.
https://github.com/llvm/llvm-project/pull/137639
More information about the llvm-commits
mailing list