The VPSHUFB 256-bit instruction may be generated when one of input vector is undefine...
[oota-llvm.git] / test / CodeGen / X86 / avx2-shuffle.ll
1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core-avx2 -mattr=+avx2 | FileCheck %s
2
3 ; Make sure that we don't match this shuffle using the vpblendw YMM instruction.
4 ; The mask for the vpblendw instruction needs to be identical for both halves
5 ; of the YMM. Need to use two vpblendw instructions.
6
7 ; CHECK: blendw1
8 ; CHECK: vpblendw
9 ; CHECK: vpblendw
10 ; CHECK: ret
11 define <16 x i16> @blendw1(<16 x i16> %a, <16 x i16> %b) nounwind alwaysinline {
12   %t = shufflevector <16 x i16> %a, <16 x i16> %b, <16 x i32> <i32 0, i32 17, i32 18, i32 3, i32 20, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 31>
13   ret <16 x i16> %t
14 }
15
16 ; CHECK: vpshufhw $27, %ymm
17 define <16 x i16> @vpshufhw(<16 x i16> %src1) nounwind uwtable readnone ssp {
18 entry:
19   %shuffle.i = shufflevector <16 x i16> %src1, <16 x i16> %src1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 7, i32 6, i32 5, i32 4, i32 8, i32 9, i32 10, i32 11, i32 15, i32 14, i32 13, i32 12>
20   ret <16 x i16> %shuffle.i
21 }
22
23 ; CHECK: vpshuflw $27, %ymm
24 define <16 x i16> @vpshuflw(<16 x i16> %src1) nounwind uwtable readnone ssp {
25 entry:
26   %shuffle.i = shufflevector <16 x i16> %src1, <16 x i16> %src1, <16 x i32> <i32 3, i32 undef, i32 1, i32 0, i32 4, i32 5, i32 6, i32 7, i32 11, i32 10, i32 9, i32 8, i32 12, i32 13, i32 14, i32 15>
27   ret <16 x i16> %shuffle.i
28 }
29
30 ; CHECK: vpshufb_test
31 ; CHECK; vpshufb {{.*\(%r.*}}, %ymm
32 ; CHECK: ret
33 define <32 x i8> @vpshufb_test(<32 x i8> %a) nounwind {
34   %S = shufflevector <32 x i8> %a, <32 x i8> undef, <32 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15, 
35                                                                 i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15,  
36                                                                 i32 18, i32 19, i32 30, i32 16, i32 25, i32 23, i32 17, i32 25, 
37                                                                 i32 20, i32 19, i32 31, i32 17, i32 23, i32 undef, i32 29, i32 18>
38   ret <32 x i8>%S
39 }
40
41 ; CHECK: vpshufb1_test
42 ; CHECK; vpshufb {{.*\(%r.*}}, %ymm
43 ; CHECK: ret
44 define <32 x i8> @vpshufb1_test(<32 x i8> %a) nounwind {
45   %S = shufflevector <32 x i8> %a, <32 x i8> zeroinitializer, <32 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15, 
46                                                                 i32 1, i32 9, i32 36, i32 11, i32 5, i32 13, i32 7, i32 15,  
47                                                                 i32 18, i32 49, i32 30, i32 16, i32 25, i32 23, i32 17, i32 25, 
48                                                                 i32 20, i32 19, i32 31, i32 17, i32 23, i32 undef, i32 29, i32 18>
49   ret <32 x i8>%S
50 }
51
52
53 ; CHECK: vpshufb2_test
54 ; CHECK; vpshufb {{.*\(%r.*}}, %ymm
55 ; CHECK: ret
56 define <32 x i8> @vpshufb2_test(<32 x i8> %a) nounwind {
57   %S = shufflevector <32 x i8> zeroinitializer, <32 x i8> %a, <32 x i32> <i32 1, i32 9, i32 3, i32 11, i32 5, i32 13, i32 7, i32 15, 
58                                                                 i32 1, i32 9, i32 36, i32 11, i32 5, i32 13, i32 7, i32 15,  
59                                                                 i32 18, i32 49, i32 30, i32 16, i32 25, i32 23, i32 17, i32 25, 
60                                                                 i32 20, i32 19, i32 31, i32 17, i32 23, i32 undef, i32 29, i32 18>
61   ret <32 x i8>%S
62 }