1; RUN: opt < %s -instcombine -mtriple=x86_64-apple-macosx -mcpu=core-avx2 -S | FileCheck %s
2
3define <2 x double> @constant_blendvpd(<2 x double> %xy, <2 x double> %ab) {
4; CHECK-LABEL: @constant_blendvpd
5; CHECK-NEXT: %1 = select <2 x i1> <i1 true, i1 false>, <2 x double> %ab, <2 x double> %xy
6; CHECK-NEXT: ret <2 x double> %1
7  %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %ab, <2 x double> <double 0xFFFFFFFFE0000000, double 0.000000e+00>)
8  ret <2 x double> %1
9}
10
11define <2 x double> @constant_blendvpd_zero(<2 x double> %xy, <2 x double> %ab) {
12; CHECK-LABEL: @constant_blendvpd_zero
13; CHECK-NEXT: ret <2 x double> %xy
14  %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %ab, <2 x double> zeroinitializer)
15  ret <2 x double> %1
16}
17
18define <2 x double> @constant_blendvpd_dup(<2 x double> %xy, <2 x double> %sel) {
19; CHECK-LABEL: @constant_blendvpd_dup
20; CHECK-NEXT: ret <2 x double> %xy
21  %1 = tail call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %xy, <2 x double> %xy, <2 x double> %sel)
22  ret <2 x double> %1
23}
24
25define <4 x float> @constant_blendvps(<4 x float> %xyzw, <4 x float> %abcd) {
26; CHECK-LABEL: @constant_blendvps
27; CHECK-NEXT: %1 = select <4 x i1> <i1 false, i1 false, i1 false, i1 true>, <4 x float> %abcd, <4 x float> %xyzw
28; CHECK-NEXT: ret <4 x float> %1
29  %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %abcd, <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0xFFFFFFFFE0000000>)
30  ret <4 x float> %1
31}
32
33define <4 x float> @constant_blendvps_zero(<4 x float> %xyzw, <4 x float> %abcd) {
34; CHECK-LABEL: @constant_blendvps_zero
35; CHECK-NEXT: ret <4 x float> %xyzw
36  %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %abcd, <4 x float> zeroinitializer)
37  ret <4 x float> %1
38}
39
40define <4 x float> @constant_blendvps_dup(<4 x float> %xyzw, <4 x float> %sel) {
41; CHECK-LABEL: @constant_blendvps_dup
42; CHECK-NEXT: ret <4 x float> %xyzw
43  %1 = tail call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %xyzw, <4 x float> %xyzw, <4 x float> %sel)
44  ret <4 x float> %1
45}
46
47define <16 x i8> @constant_pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd) {
48; CHECK-LABEL: @constant_pblendvb
49; CHECK-NEXT: %1 = select <16 x i1> <i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false>, <16 x i8> %abcd, <16 x i8> %xyzw
50; CHECK-NEXT: ret <16 x i8> %1
51  %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd, <16 x i8> <i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0, i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0>)
52  ret <16 x i8> %1
53}
54
55define <16 x i8> @constant_pblendvb_zero(<16 x i8> %xyzw, <16 x i8> %abcd) {
56; CHECK-LABEL: @constant_pblendvb_zero
57; CHECK-NEXT: ret <16 x i8> %xyzw
58  %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %abcd, <16 x i8> zeroinitializer)
59  ret <16 x i8> %1
60}
61
62define <16 x i8> @constant_pblendvb_dup(<16 x i8> %xyzw, <16 x i8> %sel) {
63; CHECK-LABEL: @constant_pblendvb_dup
64; CHECK-NEXT: ret <16 x i8> %xyzw
65  %1 = tail call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %xyzw, <16 x i8> %xyzw, <16 x i8> %sel)
66  ret <16 x i8> %1
67}
68
69define <4 x double> @constant_blendvpd_avx(<4 x double> %xy, <4 x double> %ab) {
70; CHECK-LABEL: @constant_blendvpd_avx
71; CHECK-NEXT: %1 = select <4 x i1> <i1 true, i1 false, i1 true, i1 false>, <4 x double> %ab, <4 x double> %xy
72; CHECK-NEXT: ret <4 x double> %1
73  %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %ab, <4 x double> <double 0xFFFFFFFFE0000000, double 0.000000e+00, double 0xFFFFFFFFE0000000, double 0.000000e+00>)
74  ret <4 x double> %1
75}
76
77define <4 x double> @constant_blendvpd_avx_zero(<4 x double> %xy, <4 x double> %ab) {
78; CHECK-LABEL: @constant_blendvpd_avx_zero
79; CHECK-NEXT: ret <4 x double> %xy
80  %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %ab, <4 x double> zeroinitializer)
81  ret <4 x double> %1
82}
83
84define <4 x double> @constant_blendvpd_avx_dup(<4 x double> %xy, <4 x double> %sel) {
85; CHECK-LABEL: @constant_blendvpd_avx_dup
86; CHECK-NEXT: ret <4 x double> %xy
87  %1 = tail call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %xy, <4 x double> %xy, <4 x double> %sel)
88  ret <4 x double> %1
89}
90
91define <8 x float> @constant_blendvps_avx(<8 x float> %xyzw, <8 x float> %abcd) {
92; CHECK-LABEL: @constant_blendvps_avx
93; CHECK-NEXT: %1 = select <8 x i1> <i1 false, i1 false, i1 false, i1 true, i1 false, i1 false, i1 false, i1 true>, <8 x float> %abcd, <8 x float> %xyzw
94; CHECK-NEXT: ret <8 x float> %1
95  %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %abcd, <8 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0xFFFFFFFFE0000000, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0xFFFFFFFFE0000000>)
96  ret <8 x float> %1
97}
98
99define <8 x float> @constant_blendvps_avx_zero(<8 x float> %xyzw, <8 x float> %abcd) {
100; CHECK-LABEL: @constant_blendvps_avx_zero
101; CHECK-NEXT: ret <8 x float> %xyzw
102  %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %abcd, <8 x float> zeroinitializer)
103  ret <8 x float> %1
104}
105
106define <8 x float> @constant_blendvps_avx_dup(<8 x float> %xyzw, <8 x float> %sel) {
107; CHECK-LABEL: @constant_blendvps_avx_dup
108; CHECK-NEXT: ret <8 x float> %xyzw
109  %1 = tail call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %xyzw, <8 x float> %xyzw, <8 x float> %sel)
110  ret <8 x float> %1
111}
112
113define <32 x i8> @constant_pblendvb_avx2(<32 x i8> %xyzw, <32 x i8> %abcd) {
114; CHECK-LABEL: @constant_pblendvb_avx2
115; CHECK-NEXT: %1 = select <32 x i1> <i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 true, i1 false, i1 true, i1 true, i1 true, i1 false>, <32 x i8> %abcd, <32 x i8> %xyzw
116; CHECK-NEXT: ret <32 x i8> %1
117  %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %abcd,
118        <32 x i8> <i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0,
119                   i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0,
120                   i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0,
121                   i8 0, i8 0, i8 255, i8 0, i8 255, i8 255, i8 255, i8 0>)
122  ret <32 x i8> %1
123}
124
125define <32 x i8> @constant_pblendvb_avx2_zero(<32 x i8> %xyzw, <32 x i8> %abcd) {
126; CHECK-LABEL: @constant_pblendvb_avx2_zero
127; CHECK-NEXT: ret <32 x i8> %xyzw
128  %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %abcd, <32 x i8> zeroinitializer)
129  ret <32 x i8> %1
130}
131
132define <32 x i8> @constant_pblendvb_avx2_dup(<32 x i8> %xyzw, <32 x i8> %sel) {
133; CHECK-LABEL: @constant_pblendvb_avx2_dup
134; CHECK-NEXT: ret <32 x i8> %xyzw
135  %1 = tail call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %xyzw, <32 x i8> %xyzw, <32 x i8> %sel)
136  ret <32 x i8> %1
137}
138
139declare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>)
140declare <4 x float> @llvm.x86.sse41.blendvps(<4 x float>, <4 x float>, <4 x float>)
141declare <2 x double> @llvm.x86.sse41.blendvpd(<2 x double>, <2 x double>, <2 x double>)
142
143declare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>)
144declare <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float>, <8 x float>, <8 x float>)
145declare <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double>, <4 x double>, <4 x double>)
146