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

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 30 02:28:11 PDT 2024


Author: Freddy Ye
Date: 2024-07-30T17:28:08+08:00
New Revision: 55357d8b92e32999aca83daab017df35e87e9ed2

URL: https://github.com/llvm/llvm-project/commit/55357d8b92e32999aca83daab017df35e87e9ed2
DIFF: https://github.com/llvm/llvm-project/commit/55357d8b92e32999aca83daab017df35e87e9ed2.diff

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

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

Added: 
    

Modified: 
    llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
    llvm/test/MC/X86/apx/ccmp-att.s
    llvm/test/MC/X86/apx/ccmp-intel.s
    llvm/test/MC/X86/apx/ctest-att.s
    llvm/test/MC/X86/apx/ctest-intel.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index c7f88fed9b128..6e17150edf278 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3776,6 +3776,17 @@ bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
   if (X86::optimizeShiftRotateWithImmediateOne(Inst))
     return true;
 
+  auto replaceWithCCMPCTEST = [&](unsigned Opcode) -> bool {
+    if (ForcedOpcodePrefix == OpcodePrefix_EVEX) {
+      Inst.setFlags(~(X86::IP_USE_EVEX)&Inst.getFlags());
+      Inst.setOpcode(Opcode);
+      Inst.addOperand(MCOperand::createImm(0));
+      Inst.addOperand(MCOperand::createImm(10));
+      return true;
+    }
+    return false;
+  };
+
   switch (Inst.getOpcode()) {
   default: return false;
   case X86::JMP_1:
@@ -3807,6 +3818,61 @@ bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
     Inst.setOpcode(X86::INT3);
     return true;
   }
+  // `{evex} cmp <>, <>` is alias of `ccmpt {dfv=} <>, <>`, and
+  // `{evex} test <>, <>` is alias of `ctest {dfv=} <>, <>`
+#define FROM_TO(FROM, TO)                                                      \
+  case X86::FROM:                                                              \
+    return replaceWithCCMPCTEST(X86::TO);
+    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
   }
 }
 
@@ -4158,7 +4224,10 @@ unsigned X86AsmParser::checkTargetMatchPredicate(MCInst &Inst) {
       return Match_Unsupported;
     break;
   case OpcodePrefix_EVEX:
-    if ((TSFlags & X86II::EncodingMask) != X86II::EVEX)
+    if (is64BitMode() && (TSFlags & X86II::EncodingMask) != X86II::EVEX &&
+        !X86::isCMP(Opc) && !X86::isTEST(Opc))
+      return Match_Unsupported;
+    if (!is64BitMode() && (TSFlags & X86II::EncodingMask) != X86II::EVEX)
       return Match_Unsupported;
     break;
   }

diff  --git a/llvm/test/MC/X86/apx/ccmp-att.s b/llvm/test/MC/X86/apx/ccmp-att.s
index 405071b0f4310..32e6f371600bc 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,84 @@
 # 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 "ccmpt* {dfv=}"
+
+# CHECK: ccmptb	{dfv=}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x80,0x7c,0x80,0x7b,0x7b]
+         {evex} cmpb	$123, 123(%r8,%rax,4)
+# CHECK: ccmptw	{dfv=}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmpw	$123, 123(%r8,%rax,4)
+# CHECK: ccmptw	{dfv=}	$1234, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x81,0x7c,0x80,0x7b,0xd2,0x04]
+         {evex} cmpw	$1234, 123(%r8,%rax,4)
+# CHECK: ccmptl	{dfv=}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmpl	$123, 123(%r8,%rax,4)
+# CHECK: ccmptl	{dfv=}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmpl	$123456, 123(%r8,%rax,4)
+# CHECK: ccmptq	{dfv=}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmpq	$123, 123(%r8,%rax,4)
+# CHECK: ccmptq	{dfv=}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmpq	$123456, 123(%r8,%rax,4)
+# CHECK: ccmptb	{dfv=}	%bl, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x38,0x5c,0x80,0x7b]
+         {evex} cmpb	%bl, 123(%r8,%rax,4)
+# CHECK: ccmptw	{dfv=}	%dx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x39,0x54,0x80,0x7b]
+         {evex} cmpw	%dx, 123(%r8,%rax,4)
+# CHECK: ccmptl	{dfv=}	%ecx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x39,0x4c,0x80,0x7b]
+         {evex} cmpl	%ecx, 123(%r8,%rax,4)
+# CHECK: ccmptq	{dfv=}	%r9, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x39,0x4c,0x80,0x7b]
+         {evex} cmpq	%r9, 123(%r8,%rax,4)
+# CHECK: ccmptb	{dfv=}	123(%r8,%rax,4), %bl
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x3a,0x5c,0x80,0x7b]
+         {evex} cmpb	123(%r8,%rax,4), %bl
+# CHECK: ccmptw	{dfv=}	123(%r8,%rax,4), %dx
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x3b,0x54,0x80,0x7b]
+         {evex} cmpw	123(%r8,%rax,4), %dx
+# CHECK: ccmptl	{dfv=}	123(%r8,%rax,4), %ecx
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x3b,0x4c,0x80,0x7b]
+         {evex} cmpl	123(%r8,%rax,4), %ecx
+# CHECK: ccmptq	{dfv=}	123(%r8,%rax,4), %r9
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x3b,0x4c,0x80,0x7b]
+         {evex} cmpq	123(%r8,%rax,4), %r9
+# CHECK: ccmptb	{dfv=}	$123, %bl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x80,0xfb,0x7b]
+         {evex} cmpb	$123, %bl
+# CHECK: ccmptw	{dfv=}	$123, %dx
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x83,0xfa,0x7b]
+         {evex} cmpw	$123, %dx
+# CHECK: ccmptl	{dfv=}	$123, %ecx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x83,0xf9,0x7b]
+         {evex} cmpl	$123, %ecx
+# CHECK: ccmptq	{dfv=}	$123, %r9
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x83,0xf9,0x7b]
+         {evex} cmpq	$123, %r9
+# CHECK: ccmptw	{dfv=}	$1234, %dx
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x81,0xfa,0xd2,0x04]
+         {evex} cmpw	$1234, %dx
+# CHECK: ccmptl	{dfv=}	$123456, %ecx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmpl	$123456, %ecx
+# CHECK: ccmptq	{dfv=}	$123456, %r9
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmpq	$123456, %r9
+# CHECK: ccmptb	{dfv=}	%bl, %dl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x38,0xda]
+         {evex} cmpb	%bl, %dl
+# CHECK: ccmptw	{dfv=}	%dx, %ax
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x39,0xd0]
+         {evex} cmpw	%dx, %ax
+# CHECK: ccmptl	{dfv=}	%ecx, %edx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x39,0xca]
+         {evex} cmpl	%ecx, %edx
+# CHECK: ccmptq	{dfv=}	%r9, %r15
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,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..5e64b63228cb8 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 "ccmpt* {dfv=}"
+
+# CHECK: ccmpt	{dfv=}	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x80,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpt	{dfv=}	word ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp	word ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpt	{dfv=}	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x81,0x7c,0x80,0x7b,0xd2,0x04]
+         {evex} cmp	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: ccmpt	{dfv=}	dword ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp	dword ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpt	{dfv=}	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmp	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ccmpt	{dfv=}	qword ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x83,0x7c,0x80,0x7b,0x7b]
+         {evex} cmp	qword ptr [r8 + 4*rax + 123], 123
+# CHECK: ccmpt	{dfv=}	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x81,0x7c,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} cmp	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ccmpt	{dfv=}	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x38,0x5c,0x80,0x7b]
+         {evex} cmp	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: ccmpt	{dfv=}	word ptr [r8 + 4*rax + 123], dx
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x39,0x54,0x80,0x7b]
+         {evex} cmp	word ptr [r8 + 4*rax + 123], dx
+# CHECK: ccmpt	{dfv=}	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x39,0x4c,0x80,0x7b]
+         {evex} cmp	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: ccmpt	{dfv=}	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x39,0x4c,0x80,0x7b]
+         {evex} cmp	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: ccmpt	{dfv=}	bl, byte ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x3a,0x5c,0x80,0x7b]
+         {evex} cmp	bl, byte ptr [r8 + 4*rax + 123]
+# CHECK: ccmpt	{dfv=}	dx, word ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x3b,0x54,0x80,0x7b]
+         {evex} cmp	dx, word ptr [r8 + 4*rax + 123]
+# CHECK: ccmpt	{dfv=}	ecx, dword ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x3b,0x4c,0x80,0x7b]
+         {evex} cmp	ecx, dword ptr [r8 + 4*rax + 123]
+# CHECK: ccmpt	{dfv=}	r9, qword ptr [r8 + 4*rax + 123]
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x3b,0x4c,0x80,0x7b]
+         {evex} cmp	r9, qword ptr [r8 + 4*rax + 123]
+# CHECK: ccmpt	{dfv=}	bl, 123
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x80,0xfb,0x7b]
+         {evex} cmp	bl, 123
+# CHECK: ccmpt	{dfv=}	dx, 123
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x83,0xfa,0x7b]
+         {evex} cmp	dx, 123
+# CHECK: ccmpt	{dfv=}	ecx, 123
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x83,0xf9,0x7b]
+         {evex} cmp	ecx, 123
+# CHECK: ccmpt	{dfv=}	r9, 123
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x83,0xf9,0x7b]
+         {evex} cmp	r9, 123
+# CHECK: ccmpt	{dfv=}	dx, 1234
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x81,0xfa,0xd2,0x04]
+         {evex} cmp	dx, 1234
+# CHECK: ccmpt	{dfv=}	ecx, 123456
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmp	ecx, 123456
+# CHECK: ccmpt	{dfv=}	r9, 123456
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0x81,0xf9,0x40,0xe2,0x01,0x00]
+         {evex} cmp	r9, 123456
+# CHECK: ccmpt	{dfv=}	dl, bl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x38,0xda]
+         {evex} cmp	dl, bl
+# CHECK: ccmpt	{dfv=}	ax, dx
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x39,0xd0]
+         {evex} cmp	ax, dx
+# CHECK: ccmpt	{dfv=}	edx, ecx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x39,0xca]
+         {evex} cmp	edx, ecx
+# CHECK: ccmpt	{dfv=}	r15, r9
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,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 809ffc4512da6..4cb928748a1d2 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-260: error:
+# ERROR-COUNT-276: error:
 # ERROR-NOT: error:
 # CHECK: ctestbb {dfv=of} $123, 123(%r8,%rax,4)
 # CHECK: encoding: [0x62,0xd4,0x44,0x02,0xf6,0x44,0x80,0x7b,0x7b]
@@ -784,3 +784,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 "ctestt* {dfv=}"
+
+# CHECK: ctesttb	{dfv=}	$123, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0xf6,0x44,0x80,0x7b,0x7b]
+         {evex} testb	$123, 123(%r8,%rax,4)
+# CHECK: ctesttw	{dfv=}	$1234, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0xf7,0x44,0x80,0x7b,0xd2,0x04]
+         {evex} testw	$1234, 123(%r8,%rax,4)
+# CHECK: ctesttl	{dfv=}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} testl	$123456, 123(%r8,%rax,4)
+# CHECK: ctesttq	{dfv=}	$123456, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} testq	$123456, 123(%r8,%rax,4)
+# CHECK: ctesttb	{dfv=}	%bl, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x84,0x5c,0x80,0x7b]
+         {evex} testb	%bl, 123(%r8,%rax,4)
+# CHECK: ctesttw	{dfv=}	%dx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x85,0x54,0x80,0x7b]
+         {evex} testw	%dx, 123(%r8,%rax,4)
+# CHECK: ctesttl	{dfv=}	%ecx, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x85,0x4c,0x80,0x7b]
+         {evex} testl	%ecx, 123(%r8,%rax,4)
+# CHECK: ctesttq	{dfv=}	%r9, 123(%r8,%rax,4)
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x85,0x4c,0x80,0x7b]
+         {evex} testq	%r9, 123(%r8,%rax,4)
+# CHECK: ctesttb	{dfv=}	$123, %bl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0xf6,0xc3,0x7b]
+         {evex} testb	$123, %bl
+# CHECK: ctesttw	{dfv=}	$1234, %dx
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0xf7,0xc2,0xd2,0x04]
+         {evex} testw	$1234, %dx
+# CHECK: ctesttl	{dfv=}	$123456, %ecx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} testl	$123456, %ecx
+# CHECK: ctesttq	{dfv=}	$123456, %r9
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} testq	$123456, %r9
+# CHECK: ctesttb	{dfv=}	%bl, %dl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x84,0xda]
+         {evex} testb	%bl, %dl
+# CHECK: ctesttw	{dfv=}	%dx, %ax
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x85,0xd0]
+         {evex} testw	%dx, %ax
+# CHECK: ctesttl	{dfv=}	%ecx, %edx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x85,0xca]
+         {evex} testl	%ecx, %edx
+# CHECK: ctesttq	{dfv=}	%r9, %r15
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,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 b984163069b7a..701c517e27a79 100644
--- a/llvm/test/MC/X86/apx/ctest-intel.s
+++ b/llvm/test/MC/X86/apx/ctest-intel.s
@@ -780,3 +780,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 "ctestt* {dfv=}"
+
+# CHECK: ctestt	{dfv=}	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0xf6,0x44,0x80,0x7b,0x7b]
+         {evex} test	byte ptr [r8 + 4*rax + 123], 123
+# CHECK: ctestt	{dfv=}	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0xf7,0x44,0x80,0x7b,0xd2,0x04]
+         {evex} test	word ptr [r8 + 4*rax + 123], 1234
+# CHECK: ctestt	{dfv=}	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} test	dword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ctestt	{dfv=}	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0xf7,0x44,0x80,0x7b,0x40,0xe2,0x01,0x00]
+         {evex} test	qword ptr [r8 + 4*rax + 123], 123456
+# CHECK: ctestt	{dfv=}	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x84,0x5c,0x80,0x7b]
+         {evex} test	byte ptr [r8 + 4*rax + 123], bl
+# CHECK: ctestt	{dfv=}	word ptr [r8 + 4*rax + 123], dx
+# CHECK: encoding: [0x62,0xd4,0x05,0x0a,0x85,0x54,0x80,0x7b]
+         {evex} test	word ptr [r8 + 4*rax + 123], dx
+# CHECK: ctestt	{dfv=}	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: encoding: [0x62,0xd4,0x04,0x0a,0x85,0x4c,0x80,0x7b]
+         {evex} test	dword ptr [r8 + 4*rax + 123], ecx
+# CHECK: ctestt	{dfv=}	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x85,0x4c,0x80,0x7b]
+         {evex} test	qword ptr [r8 + 4*rax + 123], r9
+# CHECK: ctestt	{dfv=}	bl, 123
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0xf6,0xc3,0x7b]
+         {evex} test	bl, 123
+# CHECK: ctestt	{dfv=}	dx, 1234
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0xf7,0xc2,0xd2,0x04]
+         {evex} test	dx, 1234
+# CHECK: ctestt	{dfv=}	ecx, 123456
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} test	ecx, 123456
+# CHECK: ctestt	{dfv=}	r9, 123456
+# CHECK: encoding: [0x62,0xd4,0x84,0x0a,0xf7,0xc1,0x40,0xe2,0x01,0x00]
+         {evex} test	r9, 123456
+# CHECK: ctestt	{dfv=}	dl, bl
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x84,0xda]
+         {evex} test	dl, bl
+# CHECK: ctestt	{dfv=}	ax, dx
+# CHECK: encoding: [0x62,0xf4,0x05,0x0a,0x85,0xd0]
+         {evex} test	ax, dx
+# CHECK: ctestt	{dfv=}	edx, ecx
+# CHECK: encoding: [0x62,0xf4,0x04,0x0a,0x85,0xca]
+         {evex} test	edx, ecx
+# CHECK: ctestt	{dfv=}	r15, r9
+# CHECK: encoding: [0x62,0x54,0x84,0x0a,0x85,0xcf]
+         {evex} test	r15, r9


        


More information about the llvm-commits mailing list