[PATCH] D151341: AMDGPU: Special case uniformity info for singlethreaded workitem IDs

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 1 23:30:06 PDT 2023


sameerds added a comment.

In D151341#4369509 <https://reviews.llvm.org/D151341#4369509>, @arsenm wrote:

> In D151341#4368708 <https://reviews.llvm.org/D151341#4368708>, @jhuber6 wrote:
>
>> In D151341#4368704 <https://reviews.llvm.org/D151341#4368704>, @arsenm wrote:
>>
>>> Ballots are forcibly uniform all the time. I guess this works for every operation and don't actually need to look for specific intrinsics
>>
>> We should be able to remove every `convergent` attribute under this special case, right.
>
> Maybe, in the future with convergence tokens we should have a convergence reduction optimization.
>
> I'm thinking a cleaner way to handle this would be to just have the divergence analysis early exit for single lane functions. Divergence cannot exist in the first place

That sounds right to me. Much simpler and assertive than checking for just a handful of intrinsics. Eventually, this can be an input to deciding whether to remove the convergent attribute, but that's a different task.



================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp:903-911
   if (const IntrinsicInst *Intrinsic = dyn_cast<IntrinsicInst>(V)) {
-    if (Intrinsic->getIntrinsicID() == Intrinsic::read_register)
+    switch (Intrinsic->getIntrinsicID()) {
+    case Intrinsic::amdgcn_workitem_id_x:
+    case Intrinsic::amdgcn_workitem_id_y:
+    case Intrinsic::amdgcn_workitem_id_z:
+      return !ST->isSingleLaneExecution(*Intrinsic->getFunction());
+    case Intrinsic::read_register:
----------------
yassingh wrote:
> Will this also work for GMIR? 
> eg "//%4:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.workitem.id.x)//"
The change is in TTI, which is clearly meant for LLVM IR. But from the rest of the comments, if we were to make this change in the UA instead, then we could make it work for both LLVM IR and MIR.


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

https://reviews.llvm.org/D151341



More information about the llvm-commits mailing list