[llvm] [X86][MC] Add alias for `{evex} cmp` and `{evex} test`. (PR #99277)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 23:46:47 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

Author: Freddy Ye (FreddyLeaf)

<details>
<summary>Changes</summary>

relate gas patch: https://sourceware.org/pipermail/binutils/2024-June/134478.html

---
Full diff: https://github.com/llvm/llvm-project/pull/99277.diff


5 Files Affected:

- (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+73-1) 
- (modified) llvm/test/MC/X86/apx/ccmp-att.s (+107-1) 
- (modified) llvm/test/MC/X86/apx/ccmp-intel.s (+81) 
- (modified) llvm/test/MC/X86/apx/ctest-att.s (+52-1) 
- (modified) llvm/test/MC/X86/apx/ctest-intel.s (+51) 


``````````diff
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index e49e96ceef6a4..8e5f713054b14 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -83,6 +83,13 @@ static const char OpPrecedence[] = {
     3   // IC_GE
 };
 
+static bool ifCmpOrTestOpcode(std::string &Opcode) {
+  return Opcode == "cmp" || Opcode == "cmpb" || Opcode == "cmpw" ||
+         Opcode == "cmpl" || Opcode == "cmpq" || Opcode == "test" ||
+         Opcode == "testb" || Opcode == "testw" || Opcode == "testl" ||
+         Opcode == "testq";
+}
+
 class X86AsmParser : public MCTargetAsmParser {
   ParseInstructionInfo *InstInfo;
   bool Code16GCC;
@@ -96,6 +103,7 @@ class X86AsmParser : public MCTargetAsmParser {
     OpcodePrefix_VEX2,
     OpcodePrefix_VEX3,
     OpcodePrefix_EVEX,
+    OpcodePrefix_EVEX_CMP_TEST,
   };
 
   OpcodePrefix ForcedOpcodePrefix = OpcodePrefix_Default;
@@ -3202,6 +3210,7 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
       if (getLexer().isNot(AsmToken::RCurly))
         return Error(Parser.getTok().getLoc(), "Expected '}'");
       Parser.Lex(); // Eat curly.
+      std::string Opcode = Parser.getTok().getString().lower();
 
       if (Prefix == "rex")
         ForcedOpcodePrefix = OpcodePrefix_REX;
@@ -3214,7 +3223,9 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
       else if (Prefix == "vex3")
         ForcedOpcodePrefix = OpcodePrefix_VEX3;
       else if (Prefix == "evex")
-        ForcedOpcodePrefix = OpcodePrefix_EVEX;
+        ForcedOpcodePrefix = is64BitMode() && ifCmpOrTestOpcode(Opcode)
+                                 ? OpcodePrefix_EVEX_CMP_TEST
+                                 : OpcodePrefix_EVEX;
       else if (Prefix == "disp8")
         ForcedDispEncoding = DispEncoding_Disp8;
       else if (Prefix == "disp32")
@@ -3784,6 +3795,66 @@ bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
     Inst.setOpcode(X86::INT3);
     return true;
   }
+#define FROM_TO(FROM, TO)                                                      \
+  case X86::FROM: {                                                            \
+    if (ForcedOpcodePrefix == OpcodePrefix_EVEX_CMP_TEST) {                    \
+      Inst.setOpcode(X86::TO);                                                 \
+      Inst.addOperand(MCOperand::createImm(15));                               \
+      Inst.addOperand(MCOperand::createImm(4));                                \
+      return true;                                                             \
+    }                                                                          \
+    return false;                                                              \
+  }
+    FROM_TO(CMP64rr, CCMP64rr)
+    FROM_TO(CMP64mi32, CCMP64mi32)
+    FROM_TO(CMP64mi8, CCMP64mi8)
+    FROM_TO(CMP64mr, CCMP64mr)
+    FROM_TO(CMP64ri32, CCMP64ri32)
+    FROM_TO(CMP64ri8, CCMP64ri8)
+    FROM_TO(CMP64rm, CCMP64rm)
+
+    FROM_TO(CMP32rr, CCMP32rr)
+    FROM_TO(CMP32mi, CCMP32mi)
+    FROM_TO(CMP32mi8, CCMP32mi8)
+    FROM_TO(CMP32mr, CCMP32mr)
+    FROM_TO(CMP32ri, CCMP32ri)
+    FROM_TO(CMP32ri8, CCMP32ri8)
+    FROM_TO(CMP32rm, CCMP32rm)
+
+    FROM_TO(CMP16rr, CCMP16rr)
+    FROM_TO(CMP16mi, CCMP16mi)
+    FROM_TO(CMP16mi8, CCMP16mi8)
+    FROM_TO(CMP16mr, CCMP16mr)
+    FROM_TO(CMP16ri, CCMP16ri)
+    FROM_TO(CMP16ri8, CCMP16ri8)
+    FROM_TO(CMP16rm, CCMP16rm)
+
+    FROM_TO(CMP8rr, CCMP8rr)
+    FROM_TO(CMP8mi, CCMP8mi)
+    FROM_TO(CMP8mr, CCMP8mr)
+    FROM_TO(CMP8ri, CCMP8ri)
+    FROM_TO(CMP8rm, CCMP8rm)
+
+    FROM_TO(TEST64rr, CTEST64rr)
+    FROM_TO(TEST64mi32, CTEST64mi32)
+    FROM_TO(TEST64mr, CTEST64mr)
+    FROM_TO(TEST64ri32, CTEST64ri32)
+
+    FROM_TO(TEST32rr, CTEST32rr)
+    FROM_TO(TEST32mi, CTEST32mi)
+    FROM_TO(TEST32mr, CTEST32mr)
+    FROM_TO(TEST32ri, CTEST32ri)
+
+    FROM_TO(TEST16rr, CTEST16rr)
+    FROM_TO(TEST16mi, CTEST16mi)
+    FROM_TO(TEST16mr, CTEST16mr)
+    FROM_TO(TEST16ri, CTEST16ri)
+
+    FROM_TO(TEST8rr, CTEST8rr)
+    FROM_TO(TEST8mi, CTEST8mi)
+    FROM_TO(TEST8mr, CTEST8mr)
+    FROM_TO(TEST8ri, CTEST8ri)
+#undef FROM_TO
   }
 }
 
@@ -4122,6 +4193,7 @@ unsigned X86AsmParser::checkTargetMatchPredicate(MCInst &Inst) {
 
   switch (ForcedOpcodePrefix) {
   case OpcodePrefix_Default:
+  case OpcodePrefix_EVEX_CMP_TEST:
     break;
   case OpcodePrefix_REX:
   case OpcodePrefix_REX2:
diff --git a/llvm/test/MC/X86/apx/ccmp-att.s b/llvm/test/MC/X86/apx/ccmp-att.s
index 405071b0f4310..10b81d2f2555d 100644
--- a/llvm/test/MC/X86/apx/ccmp-att.s
+++ b/llvm/test/MC/X86/apx/ccmp-att.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
 # RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
 
-# ERROR-COUNT-402: error:
+# ERROR-COUNT-428: error:
 # ERROR-NOT: error:
 ## Condition flags
 
@@ -1217,3 +1217,109 @@
 # CHECK: ccmpoq {dfv=of,sf,zf,cf} %rax, %rbx
 # CHECK: encoding: [0x62,0xf4,0xfc,0x00,0x39,0xc3]
          ccmpoq {dFV=Cf,zF,SF,of} %rax, %rbx
+
+## "{evex} cmp*" are alias for "ccmpe* {dfv=of,sf,zf,cf}"
+
+# CHECK: ccmpeb  {dfv=of,sf,zf,cf}       $123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x80,0x7c,0x80,0x7b,0x7b]
+{evex} cmpb $123, 123(%r8,%rax,4)
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       $123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+{evex} cmpw $123, 123(%r8,%rax,4)
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       $1234, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x81,0x7c,0x80,0x7b,0xd2,0x04]
+{evex} cmpw $1234, 123(%r8,%rax,4)
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       $123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+{evex} cmpl $123, 123(%r8,%rax,4)
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       $123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+{evex} cmpl $123456, 123(%r8,%rax,4)
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       $123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+{evex} cmpq $123, 123(%r8,%rax,4)
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       $123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+{evex} cmpq $123456, 123(%r8,%rax,4)
+
+# CHECK: ccmpeb  {dfv=of,sf,zf,cf}       %bl, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x38,0x5c,0x80,0x7b]
+{evex} cmpb %bl, 123(%r8,%rax,4)
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       %dx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x39,0x54,0x80,0x7b]
+{evex} cmpw %dx, 123(%r8,%rax,4)
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       %ecx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x39,0x4c,0x80,0x7b]
+{evex} cmpl %ecx, 123(%r8,%rax,4)
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       %r9, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x39,0x4c,0x80,0x7b]
+{evex} cmpq %r9, 123(%r8,%rax,4)
+
+# CHECK: ccmpeb  {dfv=of,sf,zf,cf}       123(%r8,%rax,4), %bl
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x3a,0x5c,0x80,0x7b]
+{evex} cmpb 123(%r8,%rax,4), %bl
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       123(%r8,%rax,4), %dx
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x3b,0x54,0x80,0x7b]
+{evex} cmpw 123(%r8,%rax,4), %dx
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       123(%r8,%rax,4), %ecx
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x3b,0x4c,0x80,0x7b]
+{evex} cmpl 123(%r8,%rax,4), %ecx
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       123(%r8,%rax,4), %r9
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x3b,0x4c,0x80,0x7b]
+{evex} cmpq 123(%r8,%rax,4), %r9
+
+# CHECK: ccmpeb  {dfv=of,sf,zf,cf}       $123, %bl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x80,0xfb,0x7b]
+{evex} cmpb $123, %bl
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       $123, %dx
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x83,0xfa,0x7b]
+{evex} cmpw $123, %dx
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       $123, %ecx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x83,0xf9,0x7b]
+{evex} cmpl $123, %ecx
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       $123, %r9
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x83,0xf9,0x7b]
+{evex} cmpq $123, %r9
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       $1234, %dx
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x81,0xfa,0xd2,0x04]
+{evex} cmpw $1234, %dx
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       $123456, %ecx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x81,0xf9,0x40,0xe2,0x01,0x00]
+{evex} cmpl $123456, %ecx
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       $123456, %r9
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x81,0xf9,0x40,0xe2,0x01,0x00]
+{evex} cmpq $123456, %r9
+
+# CHECK: ccmpeb  {dfv=of,sf,zf,cf}       %bl, %dl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x38,0xda]
+{evex} cmpb %bl, %dl
+
+# CHECK: ccmpew  {dfv=of,sf,zf,cf}       %dx, %ax
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x39,0xd0]
+{evex} cmpw %dx, %ax
+
+# CHECK: ccmpel  {dfv=of,sf,zf,cf}       %ecx, %edx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x39,0xca]
+{evex} cmpl %ecx, %edx
+
+# CHECK: ccmpeq  {dfv=of,sf,zf,cf}       %r9, %r15
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x39,0xcf]
+{evex} cmpq %r9, %r15
diff --git a/llvm/test/MC/X86/apx/ccmp-intel.s b/llvm/test/MC/X86/apx/ccmp-intel.s
index 2d446b053d94e..9123a2e6940f0 100644
--- a/llvm/test/MC/X86/apx/ccmp-intel.s
+++ b/llvm/test/MC/X86/apx/ccmp-intel.s
@@ -1214,3 +1214,84 @@
 # CHECK: ccmpo {dfv=of,sf,zf,cf} rbx, rax
 # CHECK: encoding: [0x62,0xf4,0xfc,0x00,0x39,0xc3]
          ccmpo {DFv=Cf,zF,SF,of} rbx, rax
+
+## "{evex} cmp*" are alias for "ccmpe* {dfv=of,sf,zf,cf}"
+
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       byte ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x80,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp byte ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       word ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp word ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       word ptr [r8 + 4*rax + 123], 1234
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x81,0x7c,0x80,0x7b,0xd2,0x04]
+         {evex} cmp word ptr [r8 + 4*rax + 123], 1234
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dword ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp dword ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmp dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       qword ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp qword ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmp qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       byte ptr [r8 + 4*rax + 123], bl
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x38,0x5c,0x80,0x7b]
+         {evex} cmp byte ptr [r8 + 4*rax + 123], bl
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       word ptr [r8 + 4*rax + 123], dx
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x39,0x54,0x80,0x7b]
+         {evex} cmp word ptr [r8 + 4*rax + 123], dx
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x39,0x4c,0x80,0x7b]
+         {evex} cmp dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       qword ptr [r8 + 4*rax + 123], r9
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x39,0x4c,0x80,0x7b]
+         {evex} cmp qword ptr [r8 + 4*rax + 123], r9
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       bl, byte ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x3a,0x5c,0x80,0x7b]
+         {evex} cmp bl, byte ptr [r8 + 4*rax + 123]
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dx, word ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x3b,0x54,0x80,0x7b]
+         {evex} cmp dx, word ptr [r8 + 4*rax + 123]
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       ecx, dword ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x3b,0x4c,0x80,0x7b]
+         {evex} cmp ecx, dword ptr [r8 + 4*rax + 123]
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       r9, qword ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x3b,0x4c,0x80,0x7b]
+         {evex} cmp r9, qword ptr [r8 + 4*rax + 123]
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       bl, 123
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x80,0xfb,0x7b]
+         {evex} cmp bl, 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dx, 123
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x83,0xfa,0x7b]
+         {evex} cmp dx, 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       ecx, 123
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x83,0xf9,0x7b]
+         {evex} cmp ecx, 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       r9, 123
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x83,0xf9,0x7b]
+         {evex} cmp r9, 123
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dx, 1234
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x81,0xfa,0xd2,0x04]
+         {evex} cmp dx, 1234
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       ecx, 123456
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmp ecx, 123456
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       r9, 123456
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmp r9, 123456
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       dl, bl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x38,0xda]
+         {evex} cmp dl, bl
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       ax, dx
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x39,0xd0]
+         {evex} cmp ax, dx
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       edx, ecx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x39,0xca]
+         {evex} cmp edx, ecx
+# CHECK: ccmpe   {dfv=of,sf,zf,cf}       r15, r9
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x39,0xcf]
+         {evex} cmp r15, r9
diff --git a/llvm/test/MC/X86/apx/ctest-att.s b/llvm/test/MC/X86/apx/ctest-att.s
index b9e98adc9841b..fa510f2c8fec5 100644
--- a/llvm/test/MC/X86/apx/ctest-att.s
+++ b/llvm/test/MC/X86/apx/ctest-att.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple x86_64 -show-encoding %s | FileCheck %s
 # RUN: not llvm-mc -triple i386 -show-encoding %s 2>&1 | FileCheck %s --check-prefix=ERROR
 
-# ERROR-COUNT-256: error:
+# ERROR-COUNT-272: error:
 # ERROR-NOT: error:
 # CHECK: ctestbb {dfv=of} $123, 123(%r8,%rax,4)
 # CHECK: encoding: [0x62,0xd4,0x44,0x02,0xf6,0x44,0x80,0x7b,0x7b]
@@ -771,3 +771,54 @@
 # CHECK: ctesteq {dfv=of} %r9, %r15
 # CHECK: encoding: [0x62,0x54,0xc4,0x04,0x85,0xcf]
          ctesteq {dfv=of} %r9, %r15
+
+## "{evex} test*" are alias for "cteste* {dfv=of,sf,zf,cf}"
+
+# CHECK: ctesteb	{dfv=of,sf,zf,cf}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0xf6,0x44,0x80,0x7b,0x7b]
+         {evex} testb	$123, 123(%r8,%rax,4)
+# CHECK: ctestew	{dfv=of,sf,zf,cf}	$1234, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0xf7,0x44,0x80,0x7b,0xd2,0x04]
+         {evex} testw	$1234, 123(%r8,%rax,4)
+# CHECK: ctestel	{dfv=of,sf,zf,cf}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} testl	$123456, 123(%r8,%rax,4)
+# CHECK: ctesteq	{dfv=of,sf,zf,cf}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} testq	$123456, 123(%r8,%rax,4)
+# CHECK: ctesteb	{dfv=of,sf,zf,cf}	%bl, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x84,0x5c,0x80,0x7b]
+         {evex} testb	%bl, 123(%r8,%rax,4)
+# CHECK: ctestew	{dfv=of,sf,zf,cf}	%dx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x85,0x54,0x80,0x7b]
+         {evex} testw	%dx, 123(%r8,%rax,4)
+# CHECK: ctestel	{dfv=of,sf,zf,cf}	%ecx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x85,0x4c,0x80,0x7b]
+         {evex} testl	%ecx, 123(%r8,%rax,4)
+# CHECK: ctesteq	{dfv=of,sf,zf,cf}	%r9, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x85,0x4c,0x80,0x7b]
+         {evex} testq	%r9, 123(%r8,%rax,4)
+# CHECK: ctesteb	{dfv=of,sf,zf,cf}	$123, %bl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0xf6,0xc3,0x7b]
+         {evex} testb	$123, %bl
+# CHECK: ctestew	{dfv=of,sf,zf,cf}	$1234, %dx
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0xf7,0xc2,0xd2,0x04]
+         {evex} testw	$1234, %dx
+# CHECK: ctestel	{dfv=of,sf,zf,cf}	$123456, %ecx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} testl	$123456, %ecx
+# CHECK: ctesteq	{dfv=of,sf,zf,cf}	$123456, %r9
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} testq	$123456, %r9
+# CHECK: ctesteb	{dfv=of,sf,zf,cf}	%bl, %dl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x84,0xda]
+         {evex} testb	%bl, %dl
+# CHECK: ctestew	{dfv=of,sf,zf,cf}	%dx, %ax
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x85,0xd0]
+         {evex} testw	%dx, %ax
+# CHECK: ctestel	{dfv=of,sf,zf,cf}	%ecx, %edx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x85,0xca]
+         {evex} testl	%ecx, %edx
+# CHECK: ctesteq	{dfv=of,sf,zf,cf}	%r9, %r15
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x85,0xcf]
+         {evex} testq	%r9, %r15
diff --git a/llvm/test/MC/X86/apx/ctest-intel.s b/llvm/test/MC/X86/apx/ctest-intel.s
index 17cea489b4765..23210bd75fe15 100644
--- a/llvm/test/MC/X86/apx/ctest-intel.s
+++ b/llvm/test/MC/X86/apx/ctest-intel.s
@@ -768,3 +768,54 @@
 # CHECK: cteste {dfv=of} r15, r9
 # CHECK: encoding: [0x62,0x54,0xc4,0x04,0x85,0xcf]
          cteste {dfv=of} r15, r9
+
+## "{evex} test*" are alias for "cteste* {dfv=of,sf,zf,cf}"
+
+# CHECK: cteste	{dfv=of,sf,zf,cf}	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0xf6,0x44,0x80,0x7b,0x7b]
+         {evex} test	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: cteste	{dfv=of,sf,zf,cf}	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0xf7,0x44,0x80,0x7b,0xd2,0x04]
+         {evex} test	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: cteste	{dfv=of,sf,zf,cf}	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} test	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: cteste	{dfv=of,sf,zf,cf}	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} test	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: cteste	{dfv=of,sf,zf,cf}	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x84,0x5c,0x80,0x7b]
+         {evex} test	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: cteste	{dfv=of,sf,zf,cf}	word ptr [r8 + 4*rax + 123], dx
+# CHECK: encoding: [0x62,0xd4,0x7d,0x04,0x85,0x54,0x80,0x7b]
+         {evex} test	word ptr [r8 + 4*rax + 123], dx
+# CHECK: cteste	{dfv=of,sf,zf,cf}	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: encoding: [0x62,0xd4,0x7c,0x04,0x85,0x4c,0x80,0x7b]
+         {evex} test	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: cteste	{dfv=of,sf,zf,cf}	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x85,0x4c,0x80,0x7b]
+         {evex} test	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: cteste	{dfv=of,sf,zf,cf}	bl, 123
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0xf6,0xc3,0x7b]
+         {evex} test	bl, 123
+# CHECK: cteste	{dfv=of,sf,zf,cf}	dx, 1234
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0xf7,0xc2,0xd2,0x04]
+         {evex} test	dx, 1234
+# CHECK: cteste	{dfv=of,sf,zf,cf}	ecx, 123456
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} test	ecx, 123456
+# CHECK: cteste	{dfv=of,sf,zf,cf}	r9, 123456
+# CHECK: encoding: [0x62,0xd4,0xfc,0x04,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} test	r9, 123456
+# CHECK: cteste	{dfv=of,sf,zf,cf}	dl, bl
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x84,0xda]
+         {evex} test	dl, bl
+# CHECK: cteste	{dfv=of,sf,zf,cf}	ax, dx
+# CHECK: encoding: [0x62,0xf4,0x7d,0x04,0x85,0xd0]
+         {evex} test	ax, dx
+# CHECK: cteste	{dfv=of,sf,zf,cf}	edx, ecx
+# CHECK: encoding: [0x62,0xf4,0x7c,0x04,0x85,0xca]
+         {evex} test	edx, ecx
+# CHECK: cteste	{dfv=of,sf,zf,cf}	r15, r9
+# CHECK: encoding: [0x62,0x54,0xfc,0x04,0x85,0xcf]
+         {evex} test	r15, r9

``````````

</details>


https://github.com/llvm/llvm-project/pull/99277


More information about the llvm-commits mailing list