[llvm] [AMDGPU] Bugfix for scaled MFMA parsing FP literals (PR #142493)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 2 16:16:50 PDT 2025


================
@@ -8845,12 +8852,21 @@ void AMDGPUAsmParser::cvtScaledMFMA(MCInst &Inst,
   }
 
   // Insert CBSZ and BLGP operands for F8F6F4 variants
-  int InsertPos = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::cbsz);
-  addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyCBSZ,
-                        0, InsertPos);
-  InsertPos = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::blgp);
-  addOptionalImmOperand(Inst, Operands, OptionalIdx, AMDGPUOperand::ImmTyBLGP,
-                        0, InsertPos);
+  auto CbszInsIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::cbsz);
+  auto CbszIdx = OptionalIdx.find(AMDGPUOperand::ImmTyCBSZ);
+  if (CbszIdx != OptionalIdx.end()) {
+    auto CbszVal =
+        static_cast<const AMDGPUOperand &>(*Operands[CbszIdx->second]).getImm();
+    Inst.getOperand(CbszInsIdx).setImm(CbszVal);
+  }
+
+  auto BlgpInsIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::blgp);
+  auto BlgpIdx = OptionalIdx.find(AMDGPUOperand::ImmTyBLGP);
+  if (BlgpIdx != OptionalIdx.end()) {
+    auto BlgpVal =
----------------
shiltian wrote:

no `auto` and same comment as above

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


More information about the llvm-commits mailing list