From 9933015fdd761adc1883ce87708a6aaf988031a0 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 22 Mar 2022 14:19:50 -0700 Subject: [PATCH] [X86] Fold MMX_MOVD64from64rr + store to MMX_MOVQ64mr instead of MMX_MOVD64from64mr. MMX_MOVD64from64rr moves an MMX register to a 64-bit GPR. MMX_MOVD64from64mr is the memory version of moving a MMX register to a 64-bit GPR. It requires the REX.W bit to be set. There are no isel patterns that use this instruction. MMX_MOVQ64mr is the MMX register store instruction. It doesn't require a REX.W prefix. This makes it one byte shorter to encode than MMX_MOVD64from64mr in many cases. Both store instructions output the same mnemonic string. The assembler would choose MMX_MOVQ64mr if it was to parse the output. Which is another reason using it is the correct thing to do. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D122241 --- llvm/lib/Target/X86/X86InstrFoldTables.cpp | 2 +- llvm/test/CodeGen/X86/stack-folding-mmx.ll | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/X86InstrFoldTables.cpp b/llvm/lib/Target/X86/X86InstrFoldTables.cpp index bd3360b..b8dff70 100644 --- a/llvm/lib/Target/X86/X86InstrFoldTables.cpp +++ b/llvm/lib/Target/X86/X86InstrFoldTables.cpp @@ -292,7 +292,7 @@ static const X86MemoryFoldTableEntry MemoryFoldTable0[] = { { X86::JMP32r_NT, X86::JMP32m_NT, TB_FOLDED_LOAD }, { X86::JMP64r, X86::JMP64m, TB_FOLDED_LOAD }, { X86::JMP64r_NT, X86::JMP64m_NT, TB_FOLDED_LOAD }, - { X86::MMX_MOVD64from64rr, X86::MMX_MOVD64from64mr, TB_FOLDED_STORE | TB_NO_REVERSE }, + { X86::MMX_MOVD64from64rr, X86::MMX_MOVQ64mr, TB_FOLDED_STORE | TB_NO_REVERSE }, { X86::MMX_MOVD64grr, X86::MMX_MOVD64mr, TB_FOLDED_STORE | TB_NO_REVERSE }, { X86::MOV16ri, X86::MOV16mi, TB_FOLDED_STORE }, { X86::MOV16rr, X86::MOV16mr, TB_FOLDED_STORE }, diff --git a/llvm/test/CodeGen/X86/stack-folding-mmx.ll b/llvm/test/CodeGen/X86/stack-folding-mmx.ll index 8b6c2e6..11ca9e2 100644 --- a/llvm/test/CodeGen/X86/stack-folding-mmx.ll +++ b/llvm/test/CodeGen/X86/stack-folding-mmx.ll @@ -140,7 +140,7 @@ define i64 @stack_fold_movq_store(x86_mmx %a0) nounwind { ; CHECK-NEXT: pushq %r12 ; CHECK-NEXT: pushq %rbx ; CHECK-NEXT: paddb %mm0, %mm0 -; CHECK-NEXT: movq %mm0, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Folded Spill +; CHECK-NEXT: movq %mm0, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill ; CHECK-NEXT: #APP ; CHECK-NEXT: nop ; CHECK-NEXT: #NO_APP -- 2.7.4