Skip to content

Commit 9d0b8cb

Browse files
committed
support movberr to bswap
1 parent 2f4b607 commit 9d0b8cb

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

llvm/lib/Target/X86/X86InstrMisc.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def PUSHA16 : I<0x60, RawFrm, (outs), (ins), "pushaw", []>,
229229
OpSize16, Requires<[Not64BitMode]>;
230230
}
231231

232-
let Constraints = "$src = $dst", SchedRW = [WriteBSWAP32], Predicates = [NoNDD] in {
232+
let Constraints = "$src = $dst", SchedRW = [WriteBSWAP32], Predicates = [NoNDD_Or_NoMOVBE] in {
233233
// This instruction is a consequence of BSWAP32r observing operand size. The
234234
// encoding is valid, but the behavior is undefined.
235235
let isCodeGenOnly = 1, ForceDisassemble = 1, hasSideEffects = 0 in

llvm/lib/Target/X86/X86InstrPredicates.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def HasTBM : Predicate<"Subtarget->hasTBM()">;
122122
def NoTBM : Predicate<"!Subtarget->hasTBM()">;
123123
def HasLWP : Predicate<"Subtarget->hasLWP()">;
124124
def HasMOVBE : Predicate<"Subtarget->hasMOVBE()">;
125+
def NoNDD_Or_NoMOVBE : Predicate<"!Subtarget->hasNDD() || !Subtarget->hasMOVBE()">;
125126
def HasRDRAND : Predicate<"Subtarget->hasRDRAND()">;
126127
def HasF16C : Predicate<"Subtarget->hasF16C()">;
127128
def HasFSGSBase : Predicate<"Subtarget->hasFSGSBase()">;

llvm/test/CodeGen/X86/apx/compress-evex.mir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,13 @@ body: |
7171
renamable $rax = XOR64rr_NF_ND killed renamable $rax, killed renamable $r16
7272
RET64 $rax
7373
...
74+
---
75+
name: bswapr_to_movberr
76+
body: |
77+
bb.0.entry:
78+
liveins: $rdi
79+
; CHECK: bswapq %rax # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0xcf]
80+
renamable $rax = MOVBE64rr killed renamable $rdi
81+
RET64 killed $rax
82+
83+
...

llvm/test/CodeGen/X86/movbe.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ define i64 @test7(i64 %x) nounwind {
182182
;
183183
; EGPR-LABEL: test7:
184184
; EGPR: # %bb.0:
185-
; EGPR-NEXT: movbeq %rdi, %rax # encoding: [0x62,0xf4,0xfc,0x08,0x61,0xf8]
185+
; EGPR-NEXT: bswapq %rax # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0xcf]
186186
; EGPR-NEXT: retq # encoding: [0xc3]
187187
%bswap = call i64 @llvm.bswap.i64(i64 %x)
188188
ret i64 %bswap

llvm/utils/TableGen/X86ManualCompressEVEXTables.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,6 @@ ENTRY(VBROADCASTSDZ256rm, VBROADCASTSDYrm)
328328
ENTRY(VBROADCASTSDZ256rr, VBROADCASTSDYrr)
329329
ENTRY(VPBROADCASTQZ256rm, VPBROADCASTQYrm)
330330
ENTRY(VPBROADCASTQZ256rr, VPBROADCASTQYrr)
331+
ENTRY(MOVBE32rr, BSWAP32r)
332+
ENTRY(MOVBE64rr, BSWAP64r)
331333
#undef ENTRY

0 commit comments

Comments
 (0)