[llvm] [AMDGPU] In `LowerDYNAMIC_STACKALLOC`, hoist the `readfirstlane` up one instruction (PR #201528)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 06:52:41 PDT 2026


================
@@ -4717,18 +4717,17 @@ SDValue SITargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
         DAG.getTargetConstant(Intrinsic::amdgcn_wave_reduce_umax, dl, MVT::i32);
     Size = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, MVT::i32, WaveReduction,
                        Size, DAG.getTargetConstant(0, dl, MVT::i32));
+    SDValue ReadFirstLaneID =
----------------
jmmartinez wrote:

Apparently it's not needed on GISel. I'm not familiar with the GIsel infrastructure, but I think the observer `ApplyRegBankMapping ApplyBank(B, *this, MRI, &AMDGPU::SGPRRegBank);` ends up mapping the result of the wave-reduce to the sgpr bank.

https://github.com/llvm/llvm-project/pull/201528


More information about the llvm-commits mailing list