[llvm] [AMDGPU][GlobalISel] Select s16 G_MERGE_VALUES into wider scalars (PR #207999)

Keshav Vinayak Jha via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 02:38:10 PDT 2026


================
@@ -788,7 +823,16 @@ bool AMDGPUInstructionSelector::selectG_MERGE_VALUES(MachineInstr &MI) const {
         MI.getNumOperands() == 3) {
       return selectS16MergeToS32(MI);
     }
-    return selectImpl(MI, *CoverageInfo);
+    // A scalar wider than 32 bits built from s16 pieces (with true16 a scalar
+    // s16 is a register type)
+    if (SrcSize == 16 && DstTy.getSizeInBits() > 32 &&
+        DstTy.getSizeInBits() % 32 == 0) {
+      // SGPRs have no 16-bit subregisters, so pack pairs of s16 with S_PACK.
+      if (RBI.getRegBank(DstReg, *MRI, TRI)->getID() != AMDGPU::VGPRRegBankID)
+        return selectS16MergeToWide(MI);
+    } else {
----------------
keshavvinayak01 wrote:

Refactoring.

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


More information about the llvm-commits mailing list