• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=i386-unknown-unknown -mcpu=core-avx2 < %s | FileCheck --check-prefix=BMI2 %s
3; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=core-avx2 < %s | FileCheck --check-prefix=BMI264 %s
4
5define i32 @shl32(i32 %x, i32 %shamt) nounwind uwtable readnone {
6; BMI2-LABEL: shl32:
7; BMI2:       # %bb.0:
8; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
9; BMI2-NEXT:    shlxl %eax, {{[0-9]+}}(%esp), %eax
10; BMI2-NEXT:    retl
11;
12; BMI264-LABEL: shl32:
13; BMI264:       # %bb.0:
14; BMI264-NEXT:    shlxl %esi, %edi, %eax
15; BMI264-NEXT:    retq
16  %shl = shl i32 %x, %shamt
17  ret i32 %shl
18}
19
20define i32 @shl32i(i32 %x) nounwind uwtable readnone {
21; BMI2-LABEL: shl32i:
22; BMI2:       # %bb.0:
23; BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
24; BMI2-NEXT:    shll $5, %eax
25; BMI2-NEXT:    retl
26;
27; BMI264-LABEL: shl32i:
28; BMI264:       # %bb.0:
29; BMI264-NEXT:    shll $5, %edi
30; BMI264-NEXT:    movl %edi, %eax
31; BMI264-NEXT:    retq
32  %shl = shl i32 %x, 5
33  ret i32 %shl
34}
35
36define i32 @shl32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
37; BMI2-LABEL: shl32p:
38; BMI2:       # %bb.0:
39; BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
40; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
41; BMI2-NEXT:    shlxl %ecx, (%eax), %eax
42; BMI2-NEXT:    retl
43;
44; BMI264-LABEL: shl32p:
45; BMI264:       # %bb.0:
46; BMI264-NEXT:    shlxl %esi, (%rdi), %eax
47; BMI264-NEXT:    retq
48  %x = load i32, i32* %p
49  %shl = shl i32 %x, %shamt
50  ret i32 %shl
51}
52
53define i32 @shl32pi(i32* %p) nounwind uwtable readnone {
54; BMI2-LABEL: shl32pi:
55; BMI2:       # %bb.0:
56; BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
57; BMI2-NEXT:    movl (%eax), %eax
58; BMI2-NEXT:    shll $5, %eax
59; BMI2-NEXT:    retl
60;
61; BMI264-LABEL: shl32pi:
62; BMI264:       # %bb.0:
63; BMI264-NEXT:    movl (%rdi), %eax
64; BMI264-NEXT:    shll $5, %eax
65; BMI264-NEXT:    retq
66  %x = load i32, i32* %p
67  %shl = shl i32 %x, 5
68  ret i32 %shl
69}
70
71define i64 @shl64(i64 %x, i64 %shamt) nounwind uwtable readnone {
72; BMI264-LABEL: shl64:
73; BMI264:       # %bb.0:
74; BMI264-NEXT:    shlxq %rsi, %rdi, %rax
75; BMI264-NEXT:    retq
76  %shl = shl i64 %x, %shamt
77  ret i64 %shl
78}
79
80define i64 @shl64i(i64 %x) nounwind uwtable readnone {
81; BMI264-LABEL: shl64i:
82; BMI264:       # %bb.0:
83; BMI264-NEXT:    shlq $7, %rdi
84; BMI264-NEXT:    movq %rdi, %rax
85; BMI264-NEXT:    retq
86  %shl = shl i64 %x, 7
87  ret i64 %shl
88}
89
90define i64 @shl64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
91; BMI264-LABEL: shl64p:
92; BMI264:       # %bb.0:
93; BMI264-NEXT:    shlxq %rsi, (%rdi), %rax
94; BMI264-NEXT:    retq
95  %x = load i64, i64* %p
96  %shl = shl i64 %x, %shamt
97  ret i64 %shl
98}
99
100define i64 @shl64pi(i64* %p) nounwind uwtable readnone {
101; BMI264-LABEL: shl64pi:
102; BMI264:       # %bb.0:
103; BMI264-NEXT:    movq (%rdi), %rax
104; BMI264-NEXT:    shlq $7, %rax
105; BMI264-NEXT:    retq
106  %x = load i64, i64* %p
107  %shl = shl i64 %x, 7
108  ret i64 %shl
109}
110
111define i32 @lshr32(i32 %x, i32 %shamt) nounwind uwtable readnone {
112; BMI2-LABEL: lshr32:
113; BMI2:       # %bb.0:
114; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
115; BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %eax
116; BMI2-NEXT:    retl
117;
118; BMI264-LABEL: lshr32:
119; BMI264:       # %bb.0:
120; BMI264-NEXT:    shrxl %esi, %edi, %eax
121; BMI264-NEXT:    retq
122  %shl = lshr i32 %x, %shamt
123  ret i32 %shl
124}
125
126define i32 @lshr32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
127; BMI2-LABEL: lshr32p:
128; BMI2:       # %bb.0:
129; BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
130; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
131; BMI2-NEXT:    shrxl %ecx, (%eax), %eax
132; BMI2-NEXT:    retl
133;
134; BMI264-LABEL: lshr32p:
135; BMI264:       # %bb.0:
136; BMI264-NEXT:    shrxl %esi, (%rdi), %eax
137; BMI264-NEXT:    retq
138  %x = load i32, i32* %p
139  %shl = lshr i32 %x, %shamt
140  ret i32 %shl
141}
142
143define i64 @lshr64(i64 %x, i64 %shamt) nounwind uwtable readnone {
144; BMI264-LABEL: lshr64:
145; BMI264:       # %bb.0:
146; BMI264-NEXT:    shrxq %rsi, %rdi, %rax
147; BMI264-NEXT:    retq
148  %shl = lshr i64 %x, %shamt
149  ret i64 %shl
150}
151
152define i64 @lshr64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
153; BMI264-LABEL: lshr64p:
154; BMI264:       # %bb.0:
155; BMI264-NEXT:    shrxq %rsi, (%rdi), %rax
156; BMI264-NEXT:    retq
157  %x = load i64, i64* %p
158  %shl = lshr i64 %x, %shamt
159  ret i64 %shl
160}
161
162define i32 @ashr32(i32 %x, i32 %shamt) nounwind uwtable readnone {
163; BMI2-LABEL: ashr32:
164; BMI2:       # %bb.0:
165; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
166; BMI2-NEXT:    sarxl %eax, {{[0-9]+}}(%esp), %eax
167; BMI2-NEXT:    retl
168;
169; BMI264-LABEL: ashr32:
170; BMI264:       # %bb.0:
171; BMI264-NEXT:    sarxl %esi, %edi, %eax
172; BMI264-NEXT:    retq
173  %shl = ashr i32 %x, %shamt
174  ret i32 %shl
175}
176
177define i32 @ashr32p(i32* %p, i32 %shamt) nounwind uwtable readnone {
178; BMI2-LABEL: ashr32p:
179; BMI2:       # %bb.0:
180; BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax
181; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %cl
182; BMI2-NEXT:    sarxl %ecx, (%eax), %eax
183; BMI2-NEXT:    retl
184;
185; BMI264-LABEL: ashr32p:
186; BMI264:       # %bb.0:
187; BMI264-NEXT:    sarxl %esi, (%rdi), %eax
188; BMI264-NEXT:    retq
189  %x = load i32, i32* %p
190  %shl = ashr i32 %x, %shamt
191  ret i32 %shl
192}
193
194define i64 @ashr64(i64 %x, i64 %shamt) nounwind uwtable readnone {
195; BMI264-LABEL: ashr64:
196; BMI264:       # %bb.0:
197; BMI264-NEXT:    sarxq %rsi, %rdi, %rax
198; BMI264-NEXT:    retq
199  %shl = ashr i64 %x, %shamt
200  ret i64 %shl
201}
202
203define i64 @ashr64p(i64* %p, i64 %shamt) nounwind uwtable readnone {
204; BMI264-LABEL: ashr64p:
205; BMI264:       # %bb.0:
206; BMI264-NEXT:    sarxq %rsi, (%rdi), %rax
207; BMI264-NEXT:    retq
208  %x = load i64, i64* %p
209  %shl = ashr i64 %x, %shamt
210  ret i64 %shl
211}
212
213define i32 @shl32and(i32 %t, i32 %val) nounwind {
214; BMI2-LABEL: shl32and:
215; BMI2:       # %bb.0:
216; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
217; BMI2-NEXT:    shlxl %eax, {{[0-9]+}}(%esp), %eax
218; BMI2-NEXT:    retl
219;
220; BMI264-LABEL: shl32and:
221; BMI264:       # %bb.0:
222; BMI264-NEXT:    shlxl %edi, %esi, %eax
223; BMI264-NEXT:    retq
224  %shamt = and i32 %t, 31
225  %res = shl i32 %val, %shamt
226  ret i32 %res
227}
228
229define i64 @shl64and(i64 %t, i64 %val) nounwind {
230; BMI264-LABEL: shl64and:
231; BMI264:       # %bb.0:
232; BMI264-NEXT:    shlxq %rdi, %rsi, %rax
233; BMI264-NEXT:    retq
234  %shamt = and i64 %t, 63
235  %res = shl i64 %val, %shamt
236  ret i64 %res
237}
238
239define i32 @lshr32and(i32 %t, i32 %val) nounwind {
240; BMI2-LABEL: lshr32and:
241; BMI2:       # %bb.0:
242; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
243; BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %eax
244; BMI2-NEXT:    retl
245;
246; BMI264-LABEL: lshr32and:
247; BMI264:       # %bb.0:
248; BMI264-NEXT:    shrxl %edi, %esi, %eax
249; BMI264-NEXT:    retq
250  %shamt = and i32 %t, 31
251  %res = lshr i32 %val, %shamt
252  ret i32 %res
253}
254
255define i64 @lshr64and(i64 %t, i64 %val) nounwind {
256; BMI264-LABEL: lshr64and:
257; BMI264:       # %bb.0:
258; BMI264-NEXT:    shrxq %rdi, %rsi, %rax
259; BMI264-NEXT:    retq
260  %shamt = and i64 %t, 63
261  %res = lshr i64 %val, %shamt
262  ret i64 %res
263}
264
265define i32 @ashr32and(i32 %t, i32 %val) nounwind {
266; BMI2-LABEL: ashr32and:
267; BMI2:       # %bb.0:
268; BMI2-NEXT:    movb {{[0-9]+}}(%esp), %al
269; BMI2-NEXT:    sarxl %eax, {{[0-9]+}}(%esp), %eax
270; BMI2-NEXT:    retl
271;
272; BMI264-LABEL: ashr32and:
273; BMI264:       # %bb.0:
274; BMI264-NEXT:    sarxl %edi, %esi, %eax
275; BMI264-NEXT:    retq
276  %shamt = and i32 %t, 31
277  %res = ashr i32 %val, %shamt
278  ret i32 %res
279}
280
281define i64 @ashr64and(i64 %t, i64 %val) nounwind {
282; BMI264-LABEL: ashr64and:
283; BMI264:       # %bb.0:
284; BMI264-NEXT:    sarxq %rdi, %rsi, %rax
285; BMI264-NEXT:    retq
286  %shamt = and i64 %t, 63
287  %res = ashr i64 %val, %shamt
288  ret i64 %res
289}
290