1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=corei7 | FileCheck %s --check-prefix=ALL --check-prefix=X64
3 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=corei7-avx | FileCheck %s --check-prefix=ALL --check-prefix=SHLD
4 ; RUN: llc < %s -mtriple=x86_64-- -mcpu=core-avx2 | FileCheck %s --check-prefix=ALL --check-prefix=BMI2
6 define i64 @foo(i64 %x, i64 %y, i64 %z) nounwind readnone {
8 ; ALL: # %bb.0: # %entry
9 ; ALL-NEXT: movq %rdx, %rcx
10 ; ALL-NEXT: movq %rdi, %rax
11 ; ALL-NEXT: # kill: def $cl killed $cl killed $rcx
12 ; ALL-NEXT: rolq %cl, %rax
22 define i64 @bar(i64 %x, i64 %y, i64 %z) nounwind readnone {
24 ; ALL: # %bb.0: # %entry
25 ; ALL-NEXT: movq %rdx, %rcx
26 ; ALL-NEXT: movq %rsi, %rax
27 ; ALL-NEXT: # kill: def $cl killed $cl killed $rcx
28 ; ALL-NEXT: shldq %cl, %rdi, %rax
38 define i64 @un(i64 %x, i64 %y, i64 %z) nounwind readnone {
40 ; ALL: # %bb.0: # %entry
41 ; ALL-NEXT: movq %rdx, %rcx
42 ; ALL-NEXT: movq %rdi, %rax
43 ; ALL-NEXT: # kill: def $cl killed $cl killed $rcx
44 ; ALL-NEXT: rorq %cl, %rax
54 define i64 @bu(i64 %x, i64 %y, i64 %z) nounwind readnone {
56 ; ALL: # %bb.0: # %entry
57 ; ALL-NEXT: movq %rdx, %rcx
58 ; ALL-NEXT: movq %rsi, %rax
59 ; ALL-NEXT: # kill: def $cl killed $cl killed $rcx
60 ; ALL-NEXT: shrdq %cl, %rdi, %rax
70 define i64 @xfoo(i64 %x, i64 %y, i64 %z) nounwind readnone {
72 ; X64: # %bb.0: # %entry
73 ; X64-NEXT: movq %rdi, %rax
74 ; X64-NEXT: rolq $7, %rax
78 ; SHLD: # %bb.0: # %entry
79 ; SHLD-NEXT: movq %rdi, %rax
80 ; SHLD-NEXT: shldq $7, %rax, %rax
84 ; BMI2: # %bb.0: # %entry
85 ; BMI2-NEXT: rorxq $57, %rdi, %rax
94 define i64 @xfoop(ptr %p) nounwind readnone {
96 ; X64: # %bb.0: # %entry
97 ; X64-NEXT: movq (%rdi), %rax
98 ; X64-NEXT: rolq $7, %rax
102 ; SHLD: # %bb.0: # %entry
103 ; SHLD-NEXT: movq (%rdi), %rax
104 ; SHLD-NEXT: shldq $7, %rax, %rax
108 ; BMI2: # %bb.0: # %entry
109 ; BMI2-NEXT: rorxq $57, (%rdi), %rax
112 %x = load i64, ptr %p
119 define i64 @xbar(i64 %x, i64 %y, i64 %z) nounwind readnone {
121 ; ALL: # %bb.0: # %entry
122 ; ALL-NEXT: movq %rdi, %rax
123 ; ALL-NEXT: shrdq $57, %rsi, %rax
132 define i64 @xun(i64 %x, i64 %y, i64 %z) nounwind readnone {
134 ; X64: # %bb.0: # %entry
135 ; X64-NEXT: movq %rdi, %rax
136 ; X64-NEXT: rolq $57, %rax
140 ; SHLD: # %bb.0: # %entry
141 ; SHLD-NEXT: movq %rdi, %rax
142 ; SHLD-NEXT: shldq $57, %rax, %rax
146 ; BMI2: # %bb.0: # %entry
147 ; BMI2-NEXT: rorxq $7, %rdi, %rax
156 define i64 @xunp(ptr %p) nounwind readnone {
158 ; X64: # %bb.0: # %entry
159 ; X64-NEXT: movq (%rdi), %rax
160 ; X64-NEXT: rolq $57, %rax
164 ; SHLD: # %bb.0: # %entry
165 ; SHLD-NEXT: movq (%rdi), %rax
166 ; SHLD-NEXT: shldq $57, %rax, %rax
170 ; BMI2: # %bb.0: # %entry
171 ; BMI2-NEXT: rorxq $7, (%rdi), %rax
174 %x = load i64, ptr %p
181 define i64 @xbu(i64 %x, i64 %y, i64 %z) nounwind readnone {
183 ; ALL: # %bb.0: # %entry
184 ; ALL-NEXT: movq %rdi, %rax
185 ; ALL-NEXT: shldq $57, %rsi, %rax
194 define i64 @fshl(i64 %x) nounwind {
197 ; X64-NEXT: movq %rdi, %rax
198 ; X64-NEXT: rolq $7, %rax
203 ; SHLD-NEXT: movq %rdi, %rax
204 ; SHLD-NEXT: shldq $7, %rax, %rax
209 ; BMI2-NEXT: rorxq $57, %rdi, %rax
211 %f = call i64 @llvm.fshl.i64(i64 %x, i64 %x, i64 7)
214 declare i64 @llvm.fshl.i64(i64, i64, i64)
216 define i64 @fshl1(i64 %x) nounwind {
219 ; X64-NEXT: movq %rdi, %rax
220 ; X64-NEXT: rolq %rax
225 ; SHLD-NEXT: movq %rdi, %rax
226 ; SHLD-NEXT: shldq $1, %rax, %rax
231 ; BMI2-NEXT: rorxq $63, %rdi, %rax
233 %f = call i64 @llvm.fshl.i64(i64 %x, i64 %x, i64 1)
237 define i64 @fshl63(i64 %x) nounwind {
240 ; X64-NEXT: movq %rdi, %rax
241 ; X64-NEXT: rorq %rax
244 ; SHLD-LABEL: fshl63:
246 ; SHLD-NEXT: movq %rdi, %rax
247 ; SHLD-NEXT: shldq $63, %rax, %rax
250 ; BMI2-LABEL: fshl63:
252 ; BMI2-NEXT: rorxq $1, %rdi, %rax
254 %f = call i64 @llvm.fshl.i64(i64 %x, i64 %x, i64 63)
258 define i64 @fshl_load(ptr %p) nounwind {
259 ; X64-LABEL: fshl_load:
261 ; X64-NEXT: movq (%rdi), %rax
262 ; X64-NEXT: rolq $7, %rax
265 ; SHLD-LABEL: fshl_load:
267 ; SHLD-NEXT: movq (%rdi), %rax
268 ; SHLD-NEXT: shldq $7, %rax, %rax
271 ; BMI2-LABEL: fshl_load:
273 ; BMI2-NEXT: rorxq $57, (%rdi), %rax
275 %x = load i64, ptr %p
276 %f = call i64 @llvm.fshl.i64(i64 %x, i64 %x, i64 7)
280 define i64 @fshr(i64 %x) nounwind {
283 ; X64-NEXT: movq %rdi, %rax
284 ; X64-NEXT: rorq $7, %rax
289 ; SHLD-NEXT: movq %rdi, %rax
290 ; SHLD-NEXT: shrdq $7, %rax, %rax
295 ; BMI2-NEXT: rorxq $7, %rdi, %rax
297 %f = call i64 @llvm.fshr.i64(i64 %x, i64 %x, i64 7)
300 declare i64 @llvm.fshr.i64(i64, i64, i64)
302 define i64 @fshr1(i64 %x) nounwind {
305 ; X64-NEXT: movq %rdi, %rax
306 ; X64-NEXT: rorq %rax
311 ; SHLD-NEXT: movq %rdi, %rax
312 ; SHLD-NEXT: shrdq $1, %rax, %rax
317 ; BMI2-NEXT: rorxq $1, %rdi, %rax
319 %f = call i64 @llvm.fshr.i64(i64 %x, i64 %x, i64 1)
323 define i64 @fshr63(i64 %x) nounwind {
326 ; X64-NEXT: movq %rdi, %rax
327 ; X64-NEXT: rolq %rax
330 ; SHLD-LABEL: fshr63:
332 ; SHLD-NEXT: movq %rdi, %rax
333 ; SHLD-NEXT: shrdq $63, %rax, %rax
336 ; BMI2-LABEL: fshr63:
338 ; BMI2-NEXT: rorxq $63, %rdi, %rax
340 %f = call i64 @llvm.fshr.i64(i64 %x, i64 %x, i64 63)
344 define i64 @fshr_load(ptr %p) nounwind {
345 ; X64-LABEL: fshr_load:
347 ; X64-NEXT: movq (%rdi), %rax
348 ; X64-NEXT: rorq $7, %rax
351 ; SHLD-LABEL: fshr_load:
353 ; SHLD-NEXT: movq (%rdi), %rax
354 ; SHLD-NEXT: shrdq $7, %rax, %rax
357 ; BMI2-LABEL: fshr_load:
359 ; BMI2-NEXT: rorxq $7, (%rdi), %rax
361 %x = load i64, ptr %p
362 %f = call i64 @llvm.fshr.i64(i64 %x, i64 %x, i64 7)