[X86][MC] Avoid emitting incorrect warning for complex FMUL

We will insert a new operand which is identical to the Dest for complex
FMUL with a mask. https://godbolt.org/z/eTEdnYv3q

Complex FMA and FMUL with maskz don't have this problem.

Reviewed By: LuoYuanke, skan

Differential Revision: https://reviews.llvm.org/D130638
This commit is contained in:
Phoebe Wang 2022-07-28 13:40:32 +08:00
parent ba0d079c7a
commit 726d9f8e8c
2 changed files with 10 additions and 1 deletions

View File

@ -3847,7 +3847,13 @@ bool X86AsmParser::validateInstruction(MCInst &Inst, const OperandVector &Ops) {
} else if (isVFCMULCPH(Opcode) || isVFCMULCSH(Opcode) || isVFMULCPH(Opcode) ||
isVFMULCSH(Opcode)) {
unsigned Dest = Inst.getOperand(0).getReg();
for (unsigned i = 1; i < Inst.getNumOperands(); i++)
// The mask variants have different operand list. Scan from the third
// operand to avoid emitting incorrect warning.
// VFMULCPHZrr Dest, Src1, Src2
// VFMULCPHZrrk Dest, Dest, Mask, Src1, Src2
// VFMULCPHZrrkz Dest, Mask, Src1, Src2
for (unsigned i = TSFlags & X86II::EVEX_K ? 2 : 1;
i < Inst.getNumOperands(); i++)
if (Inst.getOperand(i).isReg() && Dest == Inst.getOperand(i).getReg())
return Warning(Ops[0]->getStartLoc(), "Destination register should be "
"distinct from source registers");

View File

@ -1,4 +1,7 @@
// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding < %s | FileCheck %s
// RUN: llvm-mc -triple x86_64-unknown-unknown < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-WARN
// CHECK-NO-WARN-NOT: warning
// CHECK: vmovsh %xmm28, %xmm29, %xmm30
// CHECK: encoding: [0x62,0x05,0x16,0x00,0x10,0xf4]