• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-pc-linux -mattr=+sse2   | FileCheck %s --check-prefix=SSE --check-prefix=SSE2
3; RUN: llc < %s -mtriple=x86_64-pc-linux -mattr=+sse4.1 | FileCheck %s --check-prefix=SSE --check-prefix=SSE41
4; RUN: llc < %s -mtriple=x86_64-pc-linux -mattr=+avx    | FileCheck %s --check-prefix=AVX --check-prefix=AVX1
5; RUN: llc < %s -mtriple=x86_64-pc-linux -mattr=+avx2   | FileCheck %s --check-prefix=AVX --check-prefix=AVX2
6
7;
8; ExtractElement - Constant Index
9;
10
11define i8 @extractelement_v16i8_1(<16 x i8> %a) nounwind {
12; SSE2-LABEL: extractelement_v16i8_1:
13; SSE2:       # BB#0:
14; SSE2-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
15; SSE2-NEXT:    movb -{{[0-9]+}}(%rsp), %al
16; SSE2-NEXT:    retq
17;
18; SSE41-LABEL: extractelement_v16i8_1:
19; SSE41:       # BB#0:
20; SSE41-NEXT:    pextrb $1, %xmm0, %eax
21; SSE41-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
22; SSE41-NEXT:    retq
23;
24; AVX-LABEL: extractelement_v16i8_1:
25; AVX:       # BB#0:
26; AVX-NEXT:    vpextrb $1, %xmm0, %eax
27; AVX-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
28; AVX-NEXT:    retq
29  %b = extractelement <16 x i8> %a, i256 1
30  ret i8 %b
31}
32
33define i8 @extractelement_v16i8_11(<16 x i8> %a) nounwind {
34; SSE2-LABEL: extractelement_v16i8_11:
35; SSE2:       # BB#0:
36; SSE2-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
37; SSE2-NEXT:    movb -{{[0-9]+}}(%rsp), %al
38; SSE2-NEXT:    retq
39;
40; SSE41-LABEL: extractelement_v16i8_11:
41; SSE41:       # BB#0:
42; SSE41-NEXT:    pextrb $11, %xmm0, %eax
43; SSE41-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
44; SSE41-NEXT:    retq
45;
46; AVX-LABEL: extractelement_v16i8_11:
47; AVX:       # BB#0:
48; AVX-NEXT:    vpextrb $11, %xmm0, %eax
49; AVX-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
50; AVX-NEXT:    retq
51  %b = extractelement <16 x i8> %a, i256 11
52  ret i8 %b
53}
54
55define i8 @extractelement_v16i8_14(<16 x i8> %a) nounwind {
56; SSE2-LABEL: extractelement_v16i8_14:
57; SSE2:       # BB#0:
58; SSE2-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
59; SSE2-NEXT:    movb -{{[0-9]+}}(%rsp), %al
60; SSE2-NEXT:    retq
61;
62; SSE41-LABEL: extractelement_v16i8_14:
63; SSE41:       # BB#0:
64; SSE41-NEXT:    pextrb $14, %xmm0, %eax
65; SSE41-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
66; SSE41-NEXT:    retq
67;
68; AVX-LABEL: extractelement_v16i8_14:
69; AVX:       # BB#0:
70; AVX-NEXT:    vpextrb $14, %xmm0, %eax
71; AVX-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
72; AVX-NEXT:    retq
73  %b = extractelement <16 x i8> %a, i256 14
74  ret i8 %b
75}
76
77define i8 @extractelement_v32i8_1(<32 x i8> %a) nounwind {
78; SSE2-LABEL: extractelement_v32i8_1:
79; SSE2:       # BB#0:
80; SSE2-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
81; SSE2-NEXT:    movb -{{[0-9]+}}(%rsp), %al
82; SSE2-NEXT:    retq
83;
84; SSE41-LABEL: extractelement_v32i8_1:
85; SSE41:       # BB#0:
86; SSE41-NEXT:    pextrb $1, %xmm0, %eax
87; SSE41-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
88; SSE41-NEXT:    retq
89;
90; AVX-LABEL: extractelement_v32i8_1:
91; AVX:       # BB#0:
92; AVX-NEXT:    vpextrb $1, %xmm0, %eax
93; AVX-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
94; AVX-NEXT:    vzeroupper
95; AVX-NEXT:    retq
96  %b = extractelement <32 x i8> %a, i256 1
97  ret i8 %b
98}
99
100define i8 @extractelement_v32i8_17(<32 x i8> %a) nounwind {
101; SSE2-LABEL: extractelement_v32i8_17:
102; SSE2:       # BB#0:
103; SSE2-NEXT:    movaps %xmm1, -{{[0-9]+}}(%rsp)
104; SSE2-NEXT:    movb -{{[0-9]+}}(%rsp), %al
105; SSE2-NEXT:    retq
106;
107; SSE41-LABEL: extractelement_v32i8_17:
108; SSE41:       # BB#0:
109; SSE41-NEXT:    pextrb $1, %xmm1, %eax
110; SSE41-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
111; SSE41-NEXT:    retq
112;
113; AVX1-LABEL: extractelement_v32i8_17:
114; AVX1:       # BB#0:
115; AVX1-NEXT:    vextractf128 $1, %ymm0, %xmm0
116; AVX1-NEXT:    vpextrb $1, %xmm0, %eax
117; AVX1-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
118; AVX1-NEXT:    vzeroupper
119; AVX1-NEXT:    retq
120;
121; AVX2-LABEL: extractelement_v32i8_17:
122; AVX2:       # BB#0:
123; AVX2-NEXT:    vextracti128 $1, %ymm0, %xmm0
124; AVX2-NEXT:    vpextrb $1, %xmm0, %eax
125; AVX2-NEXT:    # kill: %AL<def> %AL<kill> %EAX<kill>
126; AVX2-NEXT:    vzeroupper
127; AVX2-NEXT:    retq
128  %b = extractelement <32 x i8> %a, i256 17
129  ret i8 %b
130}
131
132define i16 @extractelement_v8i16_0(<8 x i16> %a, i256 %i) nounwind {
133; SSE-LABEL: extractelement_v8i16_0:
134; SSE:       # BB#0:
135; SSE-NEXT:    movd %xmm0, %eax
136; SSE-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
137; SSE-NEXT:    retq
138;
139; AVX-LABEL: extractelement_v8i16_0:
140; AVX:       # BB#0:
141; AVX-NEXT:    vmovd %xmm0, %eax
142; AVX-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
143; AVX-NEXT:    retq
144  %b = extractelement <8 x i16> %a, i256 0
145  ret i16 %b
146}
147
148define i16 @extractelement_v8i16_3(<8 x i16> %a, i256 %i) nounwind {
149; SSE-LABEL: extractelement_v8i16_3:
150; SSE:       # BB#0:
151; SSE-NEXT:    pextrw $3, %xmm0, %eax
152; SSE-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
153; SSE-NEXT:    retq
154;
155; AVX-LABEL: extractelement_v8i16_3:
156; AVX:       # BB#0:
157; AVX-NEXT:    vpextrw $3, %xmm0, %eax
158; AVX-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
159; AVX-NEXT:    retq
160  %b = extractelement <8 x i16> %a, i256 3
161  ret i16 %b
162}
163
164define i16 @extractelement_v16i16_0(<16 x i16> %a, i256 %i) nounwind {
165; SSE-LABEL: extractelement_v16i16_0:
166; SSE:       # BB#0:
167; SSE-NEXT:    movd %xmm0, %eax
168; SSE-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
169; SSE-NEXT:    retq
170;
171; AVX-LABEL: extractelement_v16i16_0:
172; AVX:       # BB#0:
173; AVX-NEXT:    vmovd %xmm0, %eax
174; AVX-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
175; AVX-NEXT:    vzeroupper
176; AVX-NEXT:    retq
177  %b = extractelement <16 x i16> %a, i256 0
178  ret i16 %b
179}
180
181define i16 @extractelement_v16i16_13(<16 x i16> %a, i256 %i) nounwind {
182; SSE-LABEL: extractelement_v16i16_13:
183; SSE:       # BB#0:
184; SSE-NEXT:    pextrw $5, %xmm1, %eax
185; SSE-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
186; SSE-NEXT:    retq
187;
188; AVX1-LABEL: extractelement_v16i16_13:
189; AVX1:       # BB#0:
190; AVX1-NEXT:    vextractf128 $1, %ymm0, %xmm0
191; AVX1-NEXT:    vpextrw $5, %xmm0, %eax
192; AVX1-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
193; AVX1-NEXT:    vzeroupper
194; AVX1-NEXT:    retq
195;
196; AVX2-LABEL: extractelement_v16i16_13:
197; AVX2:       # BB#0:
198; AVX2-NEXT:    vextracti128 $1, %ymm0, %xmm0
199; AVX2-NEXT:    vpextrw $5, %xmm0, %eax
200; AVX2-NEXT:    # kill: %AX<def> %AX<kill> %EAX<kill>
201; AVX2-NEXT:    vzeroupper
202; AVX2-NEXT:    retq
203  %b = extractelement <16 x i16> %a, i256 13
204  ret i16 %b
205}
206
207define i32 @extractelement_v4i32_0(<4 x i32> %a) nounwind {
208; SSE-LABEL: extractelement_v4i32_0:
209; SSE:       # BB#0:
210; SSE-NEXT:    movd %xmm0, %eax
211; SSE-NEXT:    retq
212;
213; AVX-LABEL: extractelement_v4i32_0:
214; AVX:       # BB#0:
215; AVX-NEXT:    vmovd %xmm0, %eax
216; AVX-NEXT:    retq
217  %b = extractelement <4 x i32> %a, i256 0
218  ret i32 %b
219}
220
221define i32 @extractelement_v4i32_3(<4 x i32> %a) nounwind {
222; SSE2-LABEL: extractelement_v4i32_3:
223; SSE2:       # BB#0:
224; SSE2-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[3,1,2,3]
225; SSE2-NEXT:    movd %xmm0, %eax
226; SSE2-NEXT:    retq
227;
228; SSE41-LABEL: extractelement_v4i32_3:
229; SSE41:       # BB#0:
230; SSE41-NEXT:    pextrd $3, %xmm0, %eax
231; SSE41-NEXT:    retq
232;
233; AVX-LABEL: extractelement_v4i32_3:
234; AVX:       # BB#0:
235; AVX-NEXT:    vpextrd $3, %xmm0, %eax
236; AVX-NEXT:    retq
237  %b = extractelement <4 x i32> %a, i256 3
238  ret i32 %b
239}
240
241define i32 @extractelement_v8i32_0(<8 x i32> %a) nounwind {
242; SSE-LABEL: extractelement_v8i32_0:
243; SSE:       # BB#0:
244; SSE-NEXT:    movd %xmm1, %eax
245; SSE-NEXT:    retq
246;
247; AVX-LABEL: extractelement_v8i32_0:
248; AVX:       # BB#0:
249; AVX-NEXT:    vextractf128 $1, %ymm0, %xmm0
250; AVX-NEXT:    vmovd %xmm0, %eax
251; AVX-NEXT:    vzeroupper
252; AVX-NEXT:    retq
253  %b = extractelement <8 x i32> %a, i256 4
254  ret i32 %b
255}
256
257define i32 @extractelement_v8i32_4(<8 x i32> %a) nounwind {
258; SSE-LABEL: extractelement_v8i32_4:
259; SSE:       # BB#0:
260; SSE-NEXT:    movd %xmm1, %eax
261; SSE-NEXT:    retq
262;
263; AVX-LABEL: extractelement_v8i32_4:
264; AVX:       # BB#0:
265; AVX-NEXT:    vextractf128 $1, %ymm0, %xmm0
266; AVX-NEXT:    vmovd %xmm0, %eax
267; AVX-NEXT:    vzeroupper
268; AVX-NEXT:    retq
269  %b = extractelement <8 x i32> %a, i256 4
270  ret i32 %b
271}
272
273define i32 @extractelement_v8i32_7(<8 x i32> %a) nounwind {
274; SSE2-LABEL: extractelement_v8i32_7:
275; SSE2:       # BB#0:
276; SSE2-NEXT:    pshufd {{.*#+}} xmm0 = xmm1[3,1,2,3]
277; SSE2-NEXT:    movd %xmm0, %eax
278; SSE2-NEXT:    retq
279;
280; SSE41-LABEL: extractelement_v8i32_7:
281; SSE41:       # BB#0:
282; SSE41-NEXT:    pextrd $3, %xmm1, %eax
283; SSE41-NEXT:    retq
284;
285; AVX1-LABEL: extractelement_v8i32_7:
286; AVX1:       # BB#0:
287; AVX1-NEXT:    vextractf128 $1, %ymm0, %xmm0
288; AVX1-NEXT:    vpextrd $3, %xmm0, %eax
289; AVX1-NEXT:    vzeroupper
290; AVX1-NEXT:    retq
291;
292; AVX2-LABEL: extractelement_v8i32_7:
293; AVX2:       # BB#0:
294; AVX2-NEXT:    vextracti128 $1, %ymm0, %xmm0
295; AVX2-NEXT:    vpextrd $3, %xmm0, %eax
296; AVX2-NEXT:    vzeroupper
297; AVX2-NEXT:    retq
298  %b = extractelement <8 x i32> %a, i64 7
299  ret i32 %b
300}
301
302define i64 @extractelement_v2i64_0(<2 x i64> %a, i256 %i) nounwind {
303; SSE-LABEL: extractelement_v2i64_0:
304; SSE:       # BB#0:
305; SSE-NEXT:    movd %xmm0, %rax
306; SSE-NEXT:    retq
307;
308; AVX-LABEL: extractelement_v2i64_0:
309; AVX:       # BB#0:
310; AVX-NEXT:    vmovq %xmm0, %rax
311; AVX-NEXT:    retq
312  %b = extractelement <2 x i64> %a, i256 0
313  ret i64 %b
314}
315
316define i64 @extractelement_v2i64_1(<2 x i64> %a, i256 %i) nounwind {
317; SSE2-LABEL: extractelement_v2i64_1:
318; SSE2:       # BB#0:
319; SSE2-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
320; SSE2-NEXT:    movd %xmm0, %rax
321; SSE2-NEXT:    retq
322;
323; SSE41-LABEL: extractelement_v2i64_1:
324; SSE41:       # BB#0:
325; SSE41-NEXT:    pextrq $1, %xmm0, %rax
326; SSE41-NEXT:    retq
327;
328; AVX-LABEL: extractelement_v2i64_1:
329; AVX:       # BB#0:
330; AVX-NEXT:    vpextrq $1, %xmm0, %rax
331; AVX-NEXT:    retq
332  %b = extractelement <2 x i64> %a, i256 1
333  ret i64 %b
334}
335
336define i64 @extractelement_v4i64_1(<4 x i64> %a, i256 %i) nounwind {
337; SSE2-LABEL: extractelement_v4i64_1:
338; SSE2:       # BB#0:
339; SSE2-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
340; SSE2-NEXT:    movd %xmm0, %rax
341; SSE2-NEXT:    retq
342;
343; SSE41-LABEL: extractelement_v4i64_1:
344; SSE41:       # BB#0:
345; SSE41-NEXT:    pextrq $1, %xmm0, %rax
346; SSE41-NEXT:    retq
347;
348; AVX-LABEL: extractelement_v4i64_1:
349; AVX:       # BB#0:
350; AVX-NEXT:    vpextrq $1, %xmm0, %rax
351; AVX-NEXT:    vzeroupper
352; AVX-NEXT:    retq
353  %b = extractelement <4 x i64> %a, i256 1
354  ret i64 %b
355}
356
357define i64 @extractelement_v4i64_3(<4 x i64> %a, i256 %i) nounwind {
358; SSE2-LABEL: extractelement_v4i64_3:
359; SSE2:       # BB#0:
360; SSE2-NEXT:    pshufd {{.*#+}} xmm0 = xmm1[2,3,0,1]
361; SSE2-NEXT:    movd %xmm0, %rax
362; SSE2-NEXT:    retq
363;
364; SSE41-LABEL: extractelement_v4i64_3:
365; SSE41:       # BB#0:
366; SSE41-NEXT:    pextrq $1, %xmm1, %rax
367; SSE41-NEXT:    retq
368;
369; AVX1-LABEL: extractelement_v4i64_3:
370; AVX1:       # BB#0:
371; AVX1-NEXT:    vextractf128 $1, %ymm0, %xmm0
372; AVX1-NEXT:    vpextrq $1, %xmm0, %rax
373; AVX1-NEXT:    vzeroupper
374; AVX1-NEXT:    retq
375;
376; AVX2-LABEL: extractelement_v4i64_3:
377; AVX2:       # BB#0:
378; AVX2-NEXT:    vextracti128 $1, %ymm0, %xmm0
379; AVX2-NEXT:    vpextrq $1, %xmm0, %rax
380; AVX2-NEXT:    vzeroupper
381; AVX2-NEXT:    retq
382  %b = extractelement <4 x i64> %a, i256 3
383  ret i64 %b
384}
385
386;
387; ExtractElement - Variable Index
388;
389
390define i8 @extractelement_v16i8_var(<16 x i8> %a, i256 %i) nounwind {
391; SSE-LABEL: extractelement_v16i8_var:
392; SSE:       # BB#0:
393; SSE-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
394; SSE-NEXT:    leaq -{{[0-9]+}}(%rsp), %rax
395; SSE-NEXT:    movb (%rdi,%rax), %al
396; SSE-NEXT:    retq
397;
398; AVX-LABEL: extractelement_v16i8_var:
399; AVX:       # BB#0:
400; AVX-NEXT:    vmovaps %xmm0, -{{[0-9]+}}(%rsp)
401; AVX-NEXT:    leaq -{{[0-9]+}}(%rsp), %rax
402; AVX-NEXT:    movb (%rdi,%rax), %al
403; AVX-NEXT:    retq
404  %b = extractelement <16 x i8> %a, i256 %i
405  ret i8 %b
406}
407
408define i8 @extractelement_v32i8_var(<32 x i8> %a, i256 %i) nounwind {
409; SSE-LABEL: extractelement_v32i8_var:
410; SSE:       # BB#0:
411; SSE-NEXT:    pushq %rbp
412; SSE-NEXT:    movq %rsp, %rbp
413; SSE-NEXT:    andq $-32, %rsp
414; SSE-NEXT:    subq $64, %rsp
415; SSE-NEXT:    movaps %xmm1, {{[0-9]+}}(%rsp)
416; SSE-NEXT:    movaps %xmm0, (%rsp)
417; SSE-NEXT:    leaq (%rsp), %rax
418; SSE-NEXT:    movb (%rdi,%rax), %al
419; SSE-NEXT:    movq %rbp, %rsp
420; SSE-NEXT:    popq %rbp
421; SSE-NEXT:    retq
422;
423; AVX-LABEL: extractelement_v32i8_var:
424; AVX:       # BB#0:
425; AVX-NEXT:    pushq %rbp
426; AVX-NEXT:    movq %rsp, %rbp
427; AVX-NEXT:    andq $-32, %rsp
428; AVX-NEXT:    subq $64, %rsp
429; AVX-NEXT:    vmovaps %ymm0, (%rsp)
430; AVX-NEXT:    leaq (%rsp), %rax
431; AVX-NEXT:    movb (%rdi,%rax), %al
432; AVX-NEXT:    movq %rbp, %rsp
433; AVX-NEXT:    popq %rbp
434; AVX-NEXT:    vzeroupper
435; AVX-NEXT:    retq
436  %b = extractelement <32 x i8> %a, i256 %i
437  ret i8 %b
438}
439
440define i16 @extractelement_v8i16_var(<8 x i16> %a, i256 %i) nounwind {
441; SSE-LABEL: extractelement_v8i16_var:
442; SSE:       # BB#0:
443; SSE-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
444; SSE-NEXT:    movzwl -24(%rsp,%rdi,2), %eax
445; SSE-NEXT:    retq
446;
447; AVX-LABEL: extractelement_v8i16_var:
448; AVX:       # BB#0:
449; AVX-NEXT:    vmovaps %xmm0, -{{[0-9]+}}(%rsp)
450; AVX-NEXT:    movzwl -24(%rsp,%rdi,2), %eax
451; AVX-NEXT:    retq
452  %b = extractelement <8 x i16> %a, i256 %i
453  ret i16 %b
454}
455
456define i16 @extractelement_v16i16_var(<16 x i16> %a, i256 %i) nounwind {
457; SSE-LABEL: extractelement_v16i16_var:
458; SSE:       # BB#0:
459; SSE-NEXT:    pushq %rbp
460; SSE-NEXT:    movq %rsp, %rbp
461; SSE-NEXT:    andq $-32, %rsp
462; SSE-NEXT:    subq $64, %rsp
463; SSE-NEXT:    movaps %xmm1, {{[0-9]+}}(%rsp)
464; SSE-NEXT:    movaps %xmm0, (%rsp)
465; SSE-NEXT:    movzwl (%rsp,%rdi,2), %eax
466; SSE-NEXT:    movq %rbp, %rsp
467; SSE-NEXT:    popq %rbp
468; SSE-NEXT:    retq
469;
470; AVX-LABEL: extractelement_v16i16_var:
471; AVX:       # BB#0:
472; AVX-NEXT:    pushq %rbp
473; AVX-NEXT:    movq %rsp, %rbp
474; AVX-NEXT:    andq $-32, %rsp
475; AVX-NEXT:    subq $64, %rsp
476; AVX-NEXT:    vmovaps %ymm0, (%rsp)
477; AVX-NEXT:    movzwl (%rsp,%rdi,2), %eax
478; AVX-NEXT:    movq %rbp, %rsp
479; AVX-NEXT:    popq %rbp
480; AVX-NEXT:    vzeroupper
481; AVX-NEXT:    retq
482  %b = extractelement <16 x i16> %a, i256 %i
483  ret i16 %b
484}
485
486define i32 @extractelement_v4i32_var(<4 x i32> %a, i256 %i) nounwind {
487; SSE-LABEL: extractelement_v4i32_var:
488; SSE:       # BB#0:
489; SSE-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
490; SSE-NEXT:    movl -24(%rsp,%rdi,4), %eax
491; SSE-NEXT:    retq
492;
493; AVX-LABEL: extractelement_v4i32_var:
494; AVX:       # BB#0:
495; AVX-NEXT:    vmovaps %xmm0, -{{[0-9]+}}(%rsp)
496; AVX-NEXT:    movl -24(%rsp,%rdi,4), %eax
497; AVX-NEXT:    retq
498  %b = extractelement <4 x i32> %a, i256 %i
499  ret i32 %b
500}
501
502define i32 @extractelement_v8i32_var(<8 x i32> %a, i256 %i) nounwind {
503; SSE-LABEL: extractelement_v8i32_var:
504; SSE:       # BB#0:
505; SSE-NEXT:    pushq %rbp
506; SSE-NEXT:    movq %rsp, %rbp
507; SSE-NEXT:    andq $-32, %rsp
508; SSE-NEXT:    subq $64, %rsp
509; SSE-NEXT:    movaps %xmm1, {{[0-9]+}}(%rsp)
510; SSE-NEXT:    movaps %xmm0, (%rsp)
511; SSE-NEXT:    movl (%rsp,%rdi,4), %eax
512; SSE-NEXT:    movq %rbp, %rsp
513; SSE-NEXT:    popq %rbp
514; SSE-NEXT:    retq
515;
516; AVX1-LABEL: extractelement_v8i32_var:
517; AVX1:       # BB#0:
518; AVX1-NEXT:    pushq %rbp
519; AVX1-NEXT:    movq %rsp, %rbp
520; AVX1-NEXT:    andq $-32, %rsp
521; AVX1-NEXT:    subq $64, %rsp
522; AVX1-NEXT:    vmovaps %ymm0, (%rsp)
523; AVX1-NEXT:    movl (%rsp,%rdi,4), %eax
524; AVX1-NEXT:    movq %rbp, %rsp
525; AVX1-NEXT:    popq %rbp
526; AVX1-NEXT:    vzeroupper
527; AVX1-NEXT:    retq
528;
529; AVX2-LABEL: extractelement_v8i32_var:
530; AVX2:       # BB#0:
531; AVX2-NEXT:    vmovd %edi, %xmm1
532; AVX2-NEXT:    vpermd %ymm0, %ymm1, %ymm0
533; AVX2-NEXT:    vmovd %xmm0, %eax
534; AVX2-NEXT:    vzeroupper
535; AVX2-NEXT:    retq
536  %b = extractelement <8 x i32> %a, i256 %i
537  ret i32 %b
538}
539
540define i64 @extractelement_v2i64_var(<2 x i64> %a, i256 %i) nounwind {
541; SSE-LABEL: extractelement_v2i64_var:
542; SSE:       # BB#0:
543; SSE-NEXT:    movaps %xmm0, -{{[0-9]+}}(%rsp)
544; SSE-NEXT:    movq -24(%rsp,%rdi,8), %rax
545; SSE-NEXT:    retq
546;
547; AVX-LABEL: extractelement_v2i64_var:
548; AVX:       # BB#0:
549; AVX-NEXT:    vmovaps %xmm0, -{{[0-9]+}}(%rsp)
550; AVX-NEXT:    movq -24(%rsp,%rdi,8), %rax
551; AVX-NEXT:    retq
552  %b = extractelement <2 x i64> %a, i256 %i
553  ret i64 %b
554}
555
556define i64 @extractelement_v4i64_var(<4 x i64> %a, i256 %i) nounwind {
557; SSE-LABEL: extractelement_v4i64_var:
558; SSE:       # BB#0:
559; SSE-NEXT:    pushq %rbp
560; SSE-NEXT:    movq %rsp, %rbp
561; SSE-NEXT:    andq $-32, %rsp
562; SSE-NEXT:    subq $64, %rsp
563; SSE-NEXT:    movaps %xmm1, {{[0-9]+}}(%rsp)
564; SSE-NEXT:    movaps %xmm0, (%rsp)
565; SSE-NEXT:    movq (%rsp,%rdi,8), %rax
566; SSE-NEXT:    movq %rbp, %rsp
567; SSE-NEXT:    popq %rbp
568; SSE-NEXT:    retq
569;
570; AVX-LABEL: extractelement_v4i64_var:
571; AVX:       # BB#0:
572; AVX-NEXT:    pushq %rbp
573; AVX-NEXT:    movq %rsp, %rbp
574; AVX-NEXT:    andq $-32, %rsp
575; AVX-NEXT:    subq $64, %rsp
576; AVX-NEXT:    vmovaps %ymm0, (%rsp)
577; AVX-NEXT:    movq (%rsp,%rdi,8), %rax
578; AVX-NEXT:    movq %rbp, %rsp
579; AVX-NEXT:    popq %rbp
580; AVX-NEXT:    vzeroupper
581; AVX-NEXT:    retq
582  %b = extractelement <4 x i64> %a, i256 %i
583  ret i64 %b
584}
585
586;
587; ExtractElement - Constant (Out Of Range) Index
588;
589
590define i8 @extractelement_32i8_m1(<32 x i8> %a) nounwind {
591; SSE-LABEL: extractelement_32i8_m1:
592; SSE:       # BB#0:
593; SSE-NEXT:    retq
594;
595; AVX-LABEL: extractelement_32i8_m1:
596; AVX:       # BB#0:
597; AVX-NEXT:    retq
598  %b = extractelement <32 x i8> %a, i256 -1
599  ret i8 %b
600}
601
602define i16 @extractelement_v16i16_m4(<16 x i16> %a, i256 %i) nounwind {
603; SSE-LABEL: extractelement_v16i16_m4:
604; SSE:       # BB#0:
605; SSE-NEXT:    retq
606;
607; AVX-LABEL: extractelement_v16i16_m4:
608; AVX:       # BB#0:
609; AVX-NEXT:    retq
610  %b = extractelement <16 x i16> %a, i256 -4
611  ret i16 %b
612}
613
614define i32 @extractelement_v8i32_15(<8 x i32> %a) nounwind {
615; SSE-LABEL: extractelement_v8i32_15:
616; SSE:       # BB#0:
617; SSE-NEXT:    retq
618;
619; AVX-LABEL: extractelement_v8i32_15:
620; AVX:       # BB#0:
621; AVX-NEXT:    retq
622  %b = extractelement <8 x i32> %a, i64 15
623  ret i32 %b
624}
625
626define i64 @extractelement_v4i64_4(<4 x i64> %a, i256 %i) nounwind {
627; SSE-LABEL: extractelement_v4i64_4:
628; SSE:       # BB#0:
629; SSE-NEXT:    retq
630;
631; AVX-LABEL: extractelement_v4i64_4:
632; AVX:       # BB#0:
633; AVX-NEXT:    retq
634  %b = extractelement <4 x i64> %a, i256 4
635  ret i64 %b
636}
637