[llvm-branch-commits] [llvm] AMDGPU: Fix DPP combiner using isOperandLegal on incomplete inst (PR #155595)
Frederik Harwath via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 27 09:09:21 PDT 2025
================
@@ -431,6 +422,19 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::row_mask));
DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask));
DPPInst.addImm(CombBCZ ? 1 : 0);
+
+ for (AMDGPU::OpName Op :
+ {AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2}) {
+ int OpIdx = AMDGPU::getNamedOperandIdx(DPPOp, Op);
+ if (OpIdx == -1)
+ break;
+
+ if (!TII->isOperandLegal(*DPPInst, OpIdx)) {
+ LLVM_DEBUG(dbgs() << " failed: src operand is illegal\n");
----------------
frederik-h wrote:
> Not sure we have a way to get the name of the index from the OpName
As long as you only need to do this for the src operands, you could just replace the debug print by `LLVM_DEBUG(dbgs() << " failed: src" << i << " operand is illegal\n");` where you either keep track of the index i in the initializer list manually or you use `auto [i, OpName] : enumerate(std::array{AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2})` to iterate indices and values at the same time.
https://github.com/llvm/llvm-project/pull/155595
More information about the llvm-branch-commits
mailing list