Skip to content

Commit 726d9f8

Browse files
committed
[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
1 parent ba0d079 commit 726d9f8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

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

llvm/test/MC/X86/avx512fp16.s

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// RUN: llvm-mc -triple x86_64-unknown-unknown --show-encoding < %s | FileCheck %s
2+
// RUN: llvm-mc -triple x86_64-unknown-unknown < %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-WARN
3+
4+
// CHECK-NO-WARN-NOT: warning
25

36
// CHECK: vmovsh %xmm28, %xmm29, %xmm30
47
// CHECK: encoding: [0x62,0x05,0x16,0x00,0x10,0xf4]

0 commit comments

Comments
 (0)