diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3847,7 +3847,13 @@ } 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"); diff --git a/llvm/test/MC/X86/avx512fp16.s b/llvm/test/MC/X86/avx512fp16.s --- a/llvm/test/MC/X86/avx512fp16.s +++ b/llvm/test/MC/X86/avx512fp16.s @@ -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]