[llvm] [AMDGPU][TTI] Add Target Hook for Instruction Uniformity (getInstructionUniformity) (PR #137639)
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 02:11:29 PDT 2025
================
@@ -1422,3 +1422,24 @@ void GCNTTIImpl::collectKernelLaunchBounds(
LB.push_back({"amdgpu-waves-per-eu[0]", WavesPerEU.first});
LB.push_back({"amdgpu-waves-per-eu[1]", WavesPerEU.second});
}
+
+std::optional<InstructionUniformity>
+GCNTTIImpl::getInstructionUniformity(const Instruction &I) const {
+ if (const auto *II = dyn_cast<IntrinsicInst>(&I)) {
+ // We can define the custom rules for the intrinsics uniformity, depending
+ // on argument.
+ switch (II->getIntrinsicID()) {
+ case Intrinsic::amdgcn_permlane64:
+ // If either operand is uniform, the result is uniform.
+ for (unsigned Arg_i = 0, NumArg = II->arg_size(); Arg_i < NumArg;
+ Arg_i++) {
+ if (!isSourceOfDivergence(II->getArgOperand(Arg_i)))
----------------
ssahasra wrote:
Maybe we don't need to actually query uniformity. We could extend the enum to have something like `InstructionUniformity::SameAsOperand0`. Not exactly that, but it's information that the calling UA can then use to decide whether a returned value is uniform based on the operands.
https://github.com/llvm/llvm-project/pull/137639
More information about the llvm-commits
mailing list