1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=x86_64-linux -mcpu=atom < %s | FileCheck %s
3 ; RUN: llc -mtriple=x86_64-linux -mcpu=slm < %s | FileCheck %s -check-prefix=SLM
4 ; RUN: llc -mtriple=x86_64-linux -mattr=+egpr,+ndd,+movbe --show-mc-encoding < %s | FileCheck %s -check-prefix=EGPR
5 ; RUN: llc -mtriple=x86_64-linux -mattr=+egpr,+ndd --show-mc-encoding < %s | FileCheck %s -check-prefix=NOMOVBE
6 declare i16 @llvm.bswap.i16(i16) nounwind readnone
7 declare i32 @llvm.bswap.i32(i32) nounwind readnone
8 declare i64 @llvm.bswap.i64(i64) nounwind readnone
10 define void @test1(ptr nocapture %x, i16 %y) nounwind {
13 ; CHECK-NEXT: movbew %si, (%rdi)
24 ; SLM-NEXT: movbew %si, (%rdi)
29 ; EGPR-NEXT: movbew %si, (%rdi) # EVEX TO LEGACY Compression encoding: [0x66,0x0f,0x38,0xf1,0x37]
30 ; EGPR-NEXT: retq # encoding: [0xc3]
32 ; NOMOVBE-LABEL: test1:
34 ; NOMOVBE-NEXT: rolw $8, %si, %ax # encoding: [0x62,0xf4,0x7d,0x18,0xc1,0xc6,0x08]
35 ; NOMOVBE-NEXT: movw %ax, (%rdi) # encoding: [0x66,0x89,0x07]
36 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
37 %bswap = call i16 @llvm.bswap.i16(i16 %y)
38 store i16 %bswap, ptr %x, align 2
42 define i16 @test2(ptr %x) nounwind {
45 ; CHECK-NEXT: movbew (%rdi), %ax
56 ; SLM-NEXT: movbew (%rdi), %ax
61 ; EGPR-NEXT: movbew (%rdi), %ax # EVEX TO LEGACY Compression encoding: [0x66,0x0f,0x38,0xf0,0x07]
62 ; EGPR-NEXT: retq # encoding: [0xc3]
64 ; NOMOVBE-LABEL: test2:
66 ; NOMOVBE-NEXT: rolw $8, (%rdi), %ax # encoding: [0x62,0xf4,0x7d,0x18,0xc1,0x07,0x08]
67 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
68 %load = load i16, ptr %x, align 2
69 %bswap = call i16 @llvm.bswap.i16(i16 %load)
73 define void @test3(ptr nocapture %x, i32 %y) nounwind {
76 ; CHECK-NEXT: movbel %esi, (%rdi)
87 ; SLM-NEXT: movbel %esi, (%rdi)
92 ; EGPR-NEXT: movbel %esi, (%rdi) # EVEX TO LEGACY Compression encoding: [0x0f,0x38,0xf1,0x37]
93 ; EGPR-NEXT: retq # encoding: [0xc3]
95 ; NOMOVBE-LABEL: test3:
97 ; NOMOVBE-NEXT: bswapl %esi # encoding: [0x0f,0xce]
98 ; NOMOVBE-NEXT: movl %esi, (%rdi) # encoding: [0x89,0x37]
99 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
100 %bswap = call i32 @llvm.bswap.i32(i32 %y)
101 store i32 %bswap, ptr %x, align 4
105 define i32 @test4(ptr %x) nounwind {
106 ; CHECK-LABEL: test4:
108 ; CHECK-NEXT: movbel (%rdi), %eax
119 ; SLM-NEXT: movbel (%rdi), %eax
124 ; EGPR-NEXT: movbel (%rdi), %eax # EVEX TO LEGACY Compression encoding: [0x0f,0x38,0xf0,0x07]
125 ; EGPR-NEXT: retq # encoding: [0xc3]
127 ; NOMOVBE-LABEL: test4:
129 ; NOMOVBE-NEXT: movl (%rdi), %eax # encoding: [0x8b,0x07]
130 ; NOMOVBE-NEXT: bswapl %eax # encoding: [0x0f,0xc8]
131 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
132 %load = load i32, ptr %x, align 4
133 %bswap = call i32 @llvm.bswap.i32(i32 %load)
137 define void @test5(ptr %x, i64 %y) nounwind {
138 ; CHECK-LABEL: test5:
140 ; CHECK-NEXT: movbeq %rsi, (%rdi)
151 ; SLM-NEXT: movbeq %rsi, (%rdi)
156 ; EGPR-NEXT: movbeq %rsi, (%rdi) # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0x38,0xf1,0x37]
157 ; EGPR-NEXT: retq # encoding: [0xc3]
159 ; NOMOVBE-LABEL: test5:
161 ; NOMOVBE-NEXT: bswapq %rsi # encoding: [0x48,0x0f,0xce]
162 ; NOMOVBE-NEXT: movq %rsi, (%rdi) # encoding: [0x48,0x89,0x37]
163 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
164 %bswap = call i64 @llvm.bswap.i64(i64 %y)
165 store i64 %bswap, ptr %x, align 8
169 define i64 @test6(ptr %x) nounwind {
170 ; CHECK-LABEL: test6:
172 ; CHECK-NEXT: movbeq (%rdi), %rax
183 ; SLM-NEXT: movbeq (%rdi), %rax
188 ; EGPR-NEXT: movbeq (%rdi), %rax # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0x38,0xf0,0x07]
189 ; EGPR-NEXT: retq # encoding: [0xc3]
191 ; NOMOVBE-LABEL: test6:
193 ; NOMOVBE-NEXT: movq (%rdi), %rax # encoding: [0x48,0x8b,0x07]
194 ; NOMOVBE-NEXT: bswapq %rax # encoding: [0x48,0x0f,0xc8]
195 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
196 %load = load i64, ptr %x, align 8
197 %bswap = call i64 @llvm.bswap.i64(i64 %load)
201 define i64 @test7(i64 %x) nounwind {
202 ; CHECK-LABEL: test7:
204 ; CHECK-NEXT: movq %rdi, %rax
205 ; CHECK-NEXT: bswapq %rax
214 ; SLM-NEXT: movq %rdi, %rax
215 ; SLM-NEXT: bswapq %rax
220 ; EGPR-NEXT: movbeq %rdi, %rax # encoding: [0x62,0xf4,0xfc,0x08,0x61,0xf8]
221 ; EGPR-NEXT: retq # encoding: [0xc3]
223 ; NOMOVBE-LABEL: test7:
225 ; NOMOVBE-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]
226 ; NOMOVBE-NEXT: bswapq %rax # encoding: [0x48,0x0f,0xc8]
227 ; NOMOVBE-NEXT: retq # encoding: [0xc3]
228 %bswap = call i64 @llvm.bswap.i64(i64 %x)