diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp @@ -3471,6 +3471,9 @@ uint32_t Trunc = static_cast(Imm); return AMDGPU::isInlinableLiteralV216(Trunc, ST.hasInv2PiInlineImm()); } + case AMDGPU::OPERAND_KIMM32: + case AMDGPU::OPERAND_KIMM16: + return false; default: llvm_unreachable("invalid bitwidth"); } @@ -7307,31 +7310,19 @@ return Size; } - // 4-byte instructions may have a 32-bit literal encoded after them. Check - // operands that coud ever be literals. + // Instructions may have a 32-bit literal encoded after them. Check + // operands that could ever be literals. if (isVALU(MI) || isSALU(MI)) { - int Src0Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0); - if (Src0Idx == -1) - return DescSize; // No operands. - - if (isLiteralConstantLike(MI.getOperand(Src0Idx), Desc.OpInfo[Src0Idx])) - return isVOP3(MI) ? 12 : (DescSize + 4); - - int Src1Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src1); - if (Src1Idx == -1) - return DescSize; - - if (isLiteralConstantLike(MI.getOperand(Src1Idx), Desc.OpInfo[Src1Idx])) - return isVOP3(MI) ? 12 : (DescSize + 4); - - int Src2Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src2); - if (Src2Idx == -1) + if (isDPP(MI)) return DescSize; - - if (isLiteralConstantLike(MI.getOperand(Src2Idx), Desc.OpInfo[Src2Idx])) - return isVOP3(MI) ? 12 : (DescSize + 4); - - return DescSize; + bool HasLiteral = false; + for (int I = 0, E = MI.getNumExplicitOperands(); I != E; ++I) { + if (isLiteralConstant(MI, I)) { + HasLiteral = true; + break; + } + } + return HasLiteral ? DescSize + 4 : DescSize; } // Check whether we have extra NSA words.