Skip to content

Commit 8867ca0

Browse files
committed
Improve debug printing and add comment
1 parent 814ecb8 commit 8867ca0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,19 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
423423
DPPInst.add(*TII->getNamedOperand(MovMI, AMDGPU::OpName::bank_mask));
424424
DPPInst.addImm(CombBCZ ? 1 : 0);
425425

426-
for (AMDGPU::OpName Op :
427-
{AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2}) {
428-
int OpIdx = AMDGPU::getNamedOperandIdx(DPPOp, Op);
426+
constexpr AMDGPU::OpName Srcs[] = {
427+
AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2};
428+
429+
// FIXME: isOperandLegal expects to operate on an completely built
430+
// instruction. We should have better legality APIs to check if the
431+
// candidate operands will be legal without building the instruction first.
432+
for (auto [I, OpName] : enumerate(Srcs)) {
433+
int OpIdx = AMDGPU::getNamedOperandIdx(DPPOp, OpName);
429434
if (OpIdx == -1)
430435
break;
431436

432437
if (!TII->isOperandLegal(*DPPInst, OpIdx)) {
433-
LLVM_DEBUG(dbgs() << " failed: src operand is illegal\n");
438+
LLVM_DEBUG(dbgs() << " failed: src" << I << " operand is illegal\n");
434439
Fail = true;
435440
break;
436441
}

0 commit comments

Comments
 (0)