OSDN Git Service

94b9eaea0cc851729aace2bd2ae45c49b135d326
[android-x86/external-llvm.git] / test / CodeGen / X86 / rot64.ll
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
5
6 define i64 @foo(i64 %x, i64 %y, i64 %z) nounwind readnone {
7 ; ALL-LABEL: foo:
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
13 ; ALL-NEXT:    retq
14 entry:
15         %0 = shl i64 %x, %z
16         %1 = sub i64 64, %z
17         %2 = lshr i64 %x, %1
18         %3 = or i64 %2, %0
19         ret i64 %3
20 }
21
22 define i64 @bar(i64 %x, i64 %y, i64 %z) nounwind readnone {
23 ; ALL-LABEL: bar:
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
29 ; ALL-NEXT:    retq
30 entry:
31         %0 = shl i64 %y, %z
32         %1 = sub i64 64, %z
33         %2 = lshr i64 %x, %1
34         %3 = or i64 %2, %0
35         ret i64 %3
36 }
37
38 define i64 @un(i64 %x, i64 %y, i64 %z) nounwind readnone {
39 ; ALL-LABEL: un:
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
45 ; ALL-NEXT:    retq
46 entry:
47         %0 = lshr i64 %x, %z
48         %1 = sub i64 64, %z
49         %2 = shl i64 %x, %1
50         %3 = or i64 %2, %0
51         ret i64 %3
52 }
53
54 define i64 @bu(i64 %x, i64 %y, i64 %z) nounwind readnone {
55 ; ALL-LABEL: bu:
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
61 ; ALL-NEXT:    retq
62 entry:
63         %0 = lshr i64 %y, %z
64         %1 = sub i64 64, %z
65         %2 = shl i64 %x, %1
66         %3 = or i64 %2, %0
67         ret i64 %3
68 }
69
70 define i64 @xfoo(i64 %x, i64 %y, i64 %z) nounwind readnone {
71 ; X64-LABEL: xfoo:
72 ; X64:       # %bb.0: # %entry
73 ; X64-NEXT:    movq %rdi, %rax
74 ; X64-NEXT:    rolq $7, %rax
75 ; X64-NEXT:    retq
76 ;
77 ; SHLD-LABEL: xfoo:
78 ; SHLD:       # %bb.0: # %entry
79 ; SHLD-NEXT:    movq %rdi, %rax
80 ; SHLD-NEXT:    shldq $7, %rdi, %rax
81 ; SHLD-NEXT:    retq
82 ;
83 ; BMI2-LABEL: xfoo:
84 ; BMI2:       # %bb.0: # %entry
85 ; BMI2-NEXT:    rorxq $57, %rdi, %rax
86 ; BMI2-NEXT:    retq
87 entry:
88         %0 = lshr i64 %x, 57
89         %1 = shl i64 %x, 7
90         %2 = or i64 %0, %1
91         ret i64 %2
92 }
93
94 define i64 @xfoop(i64* %p) nounwind readnone {
95 ; X64-LABEL: xfoop:
96 ; X64:       # %bb.0: # %entry
97 ; X64-NEXT:    movq (%rdi), %rax
98 ; X64-NEXT:    rolq $7, %rax
99 ; X64-NEXT:    retq
100 ;
101 ; SHLD-LABEL: xfoop:
102 ; SHLD:       # %bb.0: # %entry
103 ; SHLD-NEXT:    movq (%rdi), %rax
104 ; SHLD-NEXT:    shldq $7, %rax, %rax
105 ; SHLD-NEXT:    retq
106 ;
107 ; BMI2-LABEL: xfoop:
108 ; BMI2:       # %bb.0: # %entry
109 ; BMI2-NEXT:    rorxq $57, (%rdi), %rax
110 ; BMI2-NEXT:    retq
111 entry:
112         %x = load i64, i64* %p
113         %a = lshr i64 %x, 57
114         %b = shl i64 %x, 7
115         %c = or i64 %a, %b
116         ret i64 %c
117 }
118
119 define i64 @xbar(i64 %x, i64 %y, i64 %z) nounwind readnone {
120 ; ALL-LABEL: xbar:
121 ; ALL:       # %bb.0: # %entry
122 ; ALL-NEXT:    movq %rdi, %rax
123 ; ALL-NEXT:    shrdq $57, %rsi, %rax
124 ; ALL-NEXT:    retq
125 entry:
126         %0 = shl i64 %y, 7
127         %1 = lshr i64 %x, 57
128         %2 = or i64 %0, %1
129         ret i64 %2
130 }
131
132 define i64 @xun(i64 %x, i64 %y, i64 %z) nounwind readnone {
133 ; X64-LABEL: xun:
134 ; X64:       # %bb.0: # %entry
135 ; X64-NEXT:    movq %rdi, %rax
136 ; X64-NEXT:    rolq $57, %rax
137 ; X64-NEXT:    retq
138 ;
139 ; SHLD-LABEL: xun:
140 ; SHLD:       # %bb.0: # %entry
141 ; SHLD-NEXT:    movq %rdi, %rax
142 ; SHLD-NEXT:    shldq $57, %rdi, %rax
143 ; SHLD-NEXT:    retq
144 ;
145 ; BMI2-LABEL: xun:
146 ; BMI2:       # %bb.0: # %entry
147 ; BMI2-NEXT:    rorxq $7, %rdi, %rax
148 ; BMI2-NEXT:    retq
149 entry:
150         %0 = lshr i64 %x, 7
151         %1 = shl i64 %x, 57
152         %2 = or i64 %0, %1
153         ret i64 %2
154 }
155
156 define i64 @xunp(i64* %p) nounwind readnone {
157 ; X64-LABEL: xunp:
158 ; X64:       # %bb.0: # %entry
159 ; X64-NEXT:    movq (%rdi), %rax
160 ; X64-NEXT:    rolq $57, %rax
161 ; X64-NEXT:    retq
162 ;
163 ; SHLD-LABEL: xunp:
164 ; SHLD:       # %bb.0: # %entry
165 ; SHLD-NEXT:    movq (%rdi), %rax
166 ; SHLD-NEXT:    shldq $57, %rax, %rax
167 ; SHLD-NEXT:    retq
168 ;
169 ; BMI2-LABEL: xunp:
170 ; BMI2:       # %bb.0: # %entry
171 ; BMI2-NEXT:    rorxq $7, (%rdi), %rax
172 ; BMI2-NEXT:    retq
173 entry:
174         %x = load i64, i64* %p
175         %a = lshr i64 %x, 7
176         %b = shl i64 %x, 57
177         %c = or i64 %a, %b
178         ret i64 %c
179 }
180
181 define i64 @xbu(i64 %x, i64 %y, i64 %z) nounwind readnone {
182 ; ALL-LABEL: xbu:
183 ; ALL:       # %bb.0: # %entry
184 ; ALL-NEXT:    movq %rdi, %rax
185 ; ALL-NEXT:    shldq $57, %rsi, %rax
186 ; ALL-NEXT:    retq
187 entry:
188         %0 = lshr i64 %y, 7
189         %1 = shl i64 %x, 57
190         %2 = or i64 %0, %1
191         ret i64 %2
192 }