[llvm] [AMDGPU][True16] Fix MadMix selection (PR #205431)

Petar Avramovic via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 03:17:26 PDT 2026


================
@@ -7225,6 +7225,13 @@ AMDGPUInstructionSelector::selectVOP3PMadMixModsImpl(MachineOperand &Root,
       Mods |= SISrcMods::OP_SEL_0;
       CheckAbsNeg();
     }
+    // Since we looked through FPEXT and removed it, we must also remove
+    // G_TRUNC. G_TRUNC to 16-bits would have a destination in RC VGPR_16, which
+    // is not compatible with MadMix instructions
+    Register PeekSrc = Src;
+    if (Subtarget->useRealTrue16Insts() &&
----------------
petar-avramovic wrote:

Looks to me that comments are missing the point, there is nothing specific with true16.
Pattern match should search for s32 sources in both cases it seems? instead of stopping at s16, and hope that slamming vgpr_32 on s16 does not break anything.
sort of "fpext in 32bit reg". pattern might be different on true16/fake16

true 16 variant might require extra pattern where inputs are really 16bit and having to insert a copy to 32bit reg and use that as input to V_FMA_MIX_F32. This pattern would needs forced lower complexity then the one that matches s32.

make some test where inputs are real 16bit dst instructions (not truncs) and fpext that into fma_mix to see what happens

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


More information about the llvm-commits mailing list