[llvm] [AMDGPU] Respect existing glue when lowering convergence tokens (PR #90834)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 01:34:03 PDT 2024


https://github.com/ssahasra updated https://github.com/llvm/llvm-project/pull/90834

>From ca8e42f1eb87184d15df73f7789cc2ce76befe6b Mon Sep 17 00:00:00 2001
From: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
Date: Thu, 2 May 2024 14:00:54 +0530
Subject: [PATCH 1/2] [AMDGPU] Respect existing glue when lowering convergence
 tokens

---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index cb4efdc7cf657c..68dffdf8060486 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3859,20 +3859,19 @@ SDValue SITargetLowering::LowerCall(CallLoweringInfo &CLI,
   assert(Mask && "Missing call preserved mask for calling convention");
   Ops.push_back(DAG.getRegisterMask(Mask));
 
-  if (InGlue.getNode())
-    Ops.push_back(InGlue);
-
-  // NOTE: This potentially results in *two* glue operands, and the wrong one
-  // might possibly show up where the other was intended. In particular,
-  // Emitter::EmitMachineNode() expects only the glued convergence token if it
-  // exists. Similarly, the selection of the call expects to match only the
-  // InGlue operand if it exists.
   if (SDValue Token = CLI.ConvergenceControlToken) {
-    Ops.push_back(SDValue(DAG.getMachineNode(TargetOpcode::CONVERGENCECTRL_GLUE,
-                                             DL, MVT::Glue, Token),
-                          0));
+    SmallVector<SDValue, 2> GlueOps;
+    GlueOps.push_back(Token);
+    if (InGlue.getNode())
+      GlueOps.push_back(InGlue);
+
+    InGlue = SDValue(DAG.getMachineNode(TargetOpcode::CONVERGENCECTRL_GLUE,
+                                       DL, MVT::Glue, GlueOps), 0);
   }
 
+  if (InGlue.getNode())
+    Ops.push_back(InGlue);
+
   SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
 
   // If we're doing a tall call, use a TC_RETURN here rather than an

>From 3a5ee8a3e42fbd83e2874c39908b10c9524e55ee Mon Sep 17 00:00:00 2001
From: Sameer Sahasrabuddhe <sameer.sahasrabuddhe at amd.com>
Date: Thu, 2 May 2024 14:05:26 +0530
Subject: [PATCH 2/2] clang format

---
 llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 68dffdf8060486..efcabdf8e48136 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -3865,8 +3865,9 @@ SDValue SITargetLowering::LowerCall(CallLoweringInfo &CLI,
     if (InGlue.getNode())
       GlueOps.push_back(InGlue);
 
-    InGlue = SDValue(DAG.getMachineNode(TargetOpcode::CONVERGENCECTRL_GLUE,
-                                       DL, MVT::Glue, GlueOps), 0);
+    InGlue = SDValue(DAG.getMachineNode(TargetOpcode::CONVERGENCECTRL_GLUE, DL,
+                                        MVT::Glue, GlueOps),
+                     0);
   }
 
   if (InGlue.getNode())



More information about the llvm-commits mailing list