[llvm] r322531 - [X86] Make 'xchgq %rax, %rax' an alias for the 0x90 nop encoding to match gas.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 22:07:15 PST 2018


Author: ctopper
Date: Mon Jan 15 22:07:14 2018
New Revision: 322531

URL: http://llvm.org/viewvc/llvm-project?rev=322531&view=rev
Log:
[X86] Make 'xchgq %rax, %rax' an alias for the 0x90 nop encoding to match gas.

Previously we encoded it as 0x48 0x90.

Modified:
    llvm/trunk/lib/Target/X86/X86InstrInfo.td
    llvm/trunk/test/MC/X86/x86-64.s

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=322531&r1=322530&r2=322531&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Jan 15 22:07:14 2018
@@ -3310,6 +3310,10 @@ def : InstAlias<"xchg{l}\t{%eax, $src|$s
                 (XCHG32ar64 GR32_NOAX:$src), 0>, Requires<[In64BitMode]>;
 def : InstAlias<"xchg{q}\t{%rax, $src|$src, rax}", (XCHG64ar GR64:$src), 0>;
 
+// xchg %rax, %rax is a nop in x86-64 and can be encoded as such. Without this
+// we emit an unneeded REX.w prefix.
+def : InstAlias<"xchg{q}\t{%rax, %rax|rax, rax}", (NOOP), 0>;
+
 // These aliases exist to get the parser to prioritize matching 8-bit
 // immediate encodings over matching the implicit ax/eax/rax encodings. By
 // explicitly mentioning the A register here, these entries will be ordered

Modified: llvm/trunk/test/MC/X86/x86-64.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-64.s?rev=322531&r1=322530&r2=322531&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/x86-64.s (original)
+++ llvm/trunk/test/MC/X86/x86-64.s Mon Jan 15 22:07:14 2018
@@ -1354,8 +1354,8 @@ pclmullqhqdq (%rdi), %xmm1
 pclmulqdq $0, (%rdi), %xmm1
 
 // PR10345
-// CHECK: xchgq %rax, %rax
-// CHECK: encoding: [0x48,0x90]
+// CHECK: nop
+// CHECK: encoding: [0x90]
 xchgq %rax, %rax
 
 // CHECK: xchgl %eax, %eax




More information about the llvm-commits mailing list