Skip to content

Commit 16a1b43

Browse files
committed
add pattern to movberr
1 parent 8058a04 commit 16a1b43

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

llvm/lib/Target/X86/X86InstrMisc.td

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,17 @@ let Predicates = [HasMOVBE, HasEGPR, In64BitMode] in {
11511151
EVEX, NoCD8, T_MAP4;
11521152
}
11531153
let SchedRW = [WriteALU] in {
1154-
def MOVBE16rr_EVEX : I<0x61, MRMDestReg, (outs), (ins GR16:$dst, GR16:$src),
1155-
"movbe{w}\t{$src, $dst|$dst, $src}", []>,
1154+
def MOVBE16rr_EVEX : I<0x61, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
1155+
"movbe{w}\t{$src, $dst|$dst, $src}",
1156+
[(set GR16:$dst, (bswap GR16:$src))]>,
11561157
EVEX, NoCD8, T_MAP4, PD;
1157-
def MOVBE32rr_EVEX : I<0x61, MRMDestReg, (outs), (ins GR32:$dst, GR32:$src),
1158-
"movbe{l}\t{$src, $dst|$dst, $src}", []>,
1158+
def MOVBE32rr_EVEX : I<0x61, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
1159+
"movbe{l}\t{$src, $dst|$dst, $src}",
1160+
[(set GR32:$dst, (bswap GR32:$src))]>,
11591161
EVEX, NoCD8, T_MAP4;
1160-
def MOVBE64rr_EVEX : RI<0x61, MRMDestReg, (outs), (ins GR64:$dst, GR64:$src),
1161-
"movbe{q}\t{$src, $dst|$dst, $src}", []>,
1162+
def MOVBE64rr_EVEX : RI<0x61, MRMDestReg, (outs GR64:$dst), (ins GR64:$src),
1163+
"movbe{q}\t{$src, $dst|$dst, $src}",
1164+
[(set GR64:$dst, (bswap GR64:$src))]>,
11621165
EVEX, NoCD8, T_MAP4;
11631166

11641167
def MOVBE16rr_EVEX_REV : I<0x60, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),

llvm/test/CodeGen/X86/movbe.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,29 @@ define i64 @test6(ptr %x) nounwind {
162162
%bswap = call i64 @llvm.bswap.i64(i64 %load)
163163
ret i64 %bswap
164164
}
165+
166+
define i64 @test7(i64 %x) nounwind {
167+
; CHECK-LABEL: test7:
168+
; CHECK: # %bb.0:
169+
; CHECK-NEXT: movq %rdi, %rax
170+
; CHECK-NEXT: bswapq %rax
171+
; CHECK-NEXT: nop
172+
; CHECK-NEXT: nop
173+
; CHECK-NEXT: nop
174+
; CHECK-NEXT: nop
175+
; CHECK-NEXT: retq
176+
;
177+
; SLM-LABEL: test7:
178+
; SLM: # %bb.0:
179+
; SLM-NEXT: movq %rdi, %rax
180+
; SLM-NEXT: bswapq %rax
181+
; SLM-NEXT: retq
182+
;
183+
; EGPR-LABEL: test7:
184+
; EGPR: # %bb.0:
185+
; EGPR-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]
186+
; EGPR-NEXT: bswapq %rax # encoding: [0x48,0x0f,0xc8]
187+
; EGPR-NEXT: retq # encoding: [0xc3]
188+
%bswap = call i64 @llvm.bswap.i64(i64 %x)
189+
ret i64 %bswap
190+
}

llvm/test/TableGen/x86-fold-tables.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ static const X86FoldTableEntry Table0[] = {
349349
{X86::MOV8rr_NOREX, X86::MOV8mr_NOREX, TB_FOLDED_STORE|TB_NO_REVERSE},
350350
{X86::MOVAPDrr, X86::MOVAPDmr, TB_FOLDED_STORE|TB_NO_REVERSE|TB_ALIGN_16},
351351
{X86::MOVAPSrr, X86::MOVAPSmr, TB_FOLDED_STORE|TB_NO_REVERSE|TB_ALIGN_16},
352-
{X86::MOVBE16rr_EVEX, X86::MOVBE16mr_EVEX, TB_FOLDED_LOAD},
353-
{X86::MOVBE32rr_EVEX, X86::MOVBE32mr_EVEX, TB_FOLDED_LOAD},
354-
{X86::MOVBE64rr_EVEX, X86::MOVBE64mr_EVEX, TB_FOLDED_LOAD},
352+
{X86::MOVBE16rr_EVEX, X86::MOVBE16mr_EVEX, TB_FOLDED_STORE},
353+
{X86::MOVBE32rr_EVEX, X86::MOVBE32mr_EVEX, TB_FOLDED_STORE},
354+
{X86::MOVBE64rr_EVEX, X86::MOVBE64mr_EVEX, TB_FOLDED_STORE},
355355
{X86::MOVDI2SSrr, X86::MOV32mr, TB_FOLDED_STORE|TB_NO_REVERSE},
356356
{X86::MOVDQArr, X86::MOVDQAmr, TB_FOLDED_STORE|TB_ALIGN_16},
357357
{X86::MOVDQUrr, X86::MOVDQUmr, TB_FOLDED_STORE},
@@ -693,6 +693,9 @@ static const X86FoldTableEntry Table1[] = {
693693
{X86::MOV8rr, X86::MOV8rm, 0},
694694
{X86::MOVAPDrr, X86::MOVAPDrm, TB_ALIGN_16},
695695
{X86::MOVAPSrr, X86::MOVAPSrm, TB_ALIGN_16},
696+
{X86::MOVBE16rr_EVEX, X86::MOVBE16rm_EVEX, 0},
697+
{X86::MOVBE32rr_EVEX, X86::MOVBE32rm_EVEX, 0},
698+
{X86::MOVBE64rr_EVEX, X86::MOVBE64rm_EVEX, 0},
696699
{X86::MOVDDUPrr, X86::MOVDDUPrm, TB_NO_REVERSE},
697700
{X86::MOVDI2PDIrr, X86::MOVDI2PDIrm, 0},
698701
{X86::MOVDI2SSrr, X86::MOVSSrm_alt, 0},

0 commit comments

Comments
 (0)