Skip to content

[AMX] Error out when AMX DP instructions use same registers #97686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3849,6 +3849,14 @@ bool X86AsmParser::validateInstruction(MCInst &Inst, const OperandVector &Ops) {
return Warning(Ops[0]->getStartLoc(), "mask, index, and destination "
"registers should be distinct");
}
} else if (isTCMMIMFP16PS(Opcode) || isTCMMRLFP16PS(Opcode) ||
isTDPBF16PS(Opcode) || isTDPFP16PS(Opcode) || isTDPBSSD(Opcode) ||
isTDPBSUD(Opcode) || isTDPBUSD(Opcode) || isTDPBUUD(Opcode)) {
unsigned SrcDest = Inst.getOperand(0).getReg();
unsigned Src1 = Inst.getOperand(2).getReg();
unsigned Src2 = Inst.getOperand(3).getReg();
if (SrcDest == Src1 || SrcDest == Src2 || Src1 == Src2)
return Error(Ops[0]->getStartLoc(), "all tmm registers must be distinct");
}

// Check that we aren't mixing AH/BH/CH/DH with REX prefix. We only need to
Expand Down
25 changes: 25 additions & 0 deletions llvm/test/MC/X86/AMX/amx-error.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// RUN: not llvm-mc -triple x86_64 %s 2>&1 | FileCheck %s

// CHECK: error: all tmm registers must be distinct
tcmmimfp16ps %tmm0, %tmm0, %tmm0

// CHECK: error: all tmm registers must be distinct
tcmmrlfp16ps %tmm1, %tmm0, %tmm1

// CHECK: error: all tmm registers must be distinct
tdpbf16ps %tmm2, %tmm2, %tmm0

// CHECK: error: all tmm registers must be distinct
tdpfp16ps %tmm3, %tmm0, %tmm0

// CHECK: error: all tmm registers must be distinct
tdpbssd %tmm0, %tmm0, %tmm0

// CHECK: error: all tmm registers must be distinct
tdpbsud %tmm1, %tmm0, %tmm1

// CHECK: error: all tmm registers must be distinct
tdpbusd %tmm2, %tmm2, %tmm0

// CHECK: error: all tmm registers must be distinct
tdpbuud %tmm3, %tmm0, %tmm0
Loading