[llvm] [AMDGPU] Select upper 16-bits for inline constants in packed BF16 (PR #209861)

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 23:58:50 PDT 2026


================
@@ -537,6 +537,14 @@ bool SIFoldOperandsImpl::tryFoldImmWithOpSel(MachineInstr *MI, unsigned UseOpNo,
     uint16_t Hi = static_cast<uint16_t>(Imm >> 16);
     if (Lo == Hi) {
       if (AMDGPU::isInlinableLiteralV216(Lo, OpType)) {
+        // Packed BF16 instructions using inline constant must use OPSEL to
+        // select the upper 16-bits
+        if (Opcode == AMDGPU::V_PK_ADD_BF16 ||
----------------
rampitec wrote:

Even if it is different I'd still make a check for operand type and then yet another target check like 'bf16 extends from top' or 'extends from bottom'. First it needs to be explicit. Second otherwise it may result in exponential explosion of checks. bf16 extending from the top is a failure of course.

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


More information about the llvm-commits mailing list