[InstCombine] Move SSE2/AVX2 arithmetic vector shift folding to instcombiner
[oota-llvm.git] / test / CodeGen / X86 / combine-avx2-intrinsics.ll
1 ; RUN: llc < %s -march=x86-64 -mcpu=core-avx2 | FileCheck %s
2
3 ; Verify that the backend correctly combines AVX2 builtin intrinsics.
4
5
6 define <32 x i8> @test_x86_avx2_pblendvb(<32 x i8> %a0, <32 x i8> %a1) {
7   %res = call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a0, <32 x i8> %a0, <32 x i8> %a1)
8   ret <32 x i8> %res
9 }
10 ; CHECK-LABEL: test_x86_avx2_pblendvb
11 ; CHECK-NOT: vpblendvb
12 ; CHECK: ret
13
14
15 define <16 x i16> @test_x86_avx2_pblendw(<16 x i16> %a0) {
16   %res = call <16 x i16> @llvm.x86.avx2.pblendw(<16 x i16> %a0, <16 x i16> %a0, i32 7)
17   ret <16 x i16> %res
18 }
19 ; CHECK-LABEL: test_x86_avx2_pblendw
20 ; CHECK-NOT: vpblendw
21 ; CHECK: ret
22
23
24 define <4 x i32> @test_x86_avx2_pblendd_128(<4 x i32> %a0) {
25   %res = call <4 x i32> @llvm.x86.avx2.pblendd.128(<4 x i32> %a0, <4 x i32> %a0, i32 7)
26   ret <4 x i32> %res
27 }
28 ; CHECK-LABEL: test_x86_avx2_pblendd_128
29 ; CHECK-NOT: vpblendd
30 ; CHECK: ret
31
32
33 define <8 x i32> @test_x86_avx2_pblendd_256(<8 x i32> %a0) {
34   %res = call <8 x i32> @llvm.x86.avx2.pblendd.256(<8 x i32> %a0, <8 x i32> %a0, i32 7)
35   ret <8 x i32> %res
36 }
37 ; CHECK-LABEL: test_x86_avx2_pblendd_256
38 ; CHECK-NOT: vpblendd
39 ; CHECK: ret
40
41
42 define <32 x i8> @test2_x86_avx2_pblendvb(<32 x i8> %a0, <32 x i8> %a1) {
43   %res = call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a0, <32 x i8> %a1, <32 x i8> zeroinitializer)
44   ret <32 x i8> %res
45 }
46 ; CHECK-LABEL: test2_x86_avx2_pblendvb
47 ; CHECK-NOT: vpblendvb
48 ; CHECK: ret
49
50
51 define <16 x i16> @test2_x86_avx2_pblendw(<16 x i16> %a0, <16 x i16> %a1) {
52   %res = call <16 x i16> @llvm.x86.avx2.pblendw(<16 x i16> %a0, <16 x i16> %a1, i32 0)
53   ret <16 x i16> %res
54 }
55 ; CHECK-LABEL: test2_x86_avx2_pblendw
56 ; CHECK-NOT: vpblendw
57 ; CHECK: ret
58
59
60 define <4 x i32> @test2_x86_avx2_pblendd_128(<4 x i32> %a0, <4 x i32> %a1) {
61   %res = call <4 x i32> @llvm.x86.avx2.pblendd.128(<4 x i32> %a0, <4 x i32> %a1, i32 0)
62   ret <4 x i32> %res
63 }
64 ; CHECK-LABEL: test2_x86_avx2_pblendd_128
65 ; CHECK-NOT: vpblendd
66 ; CHECK: ret
67
68
69 define <8 x i32> @test2_x86_avx2_pblendd_256(<8 x i32> %a0, <8 x i32> %a1) {
70   %res = call <8 x i32> @llvm.x86.avx2.pblendd.256(<8 x i32> %a0, <8 x i32> %a1, i32 0)
71   ret <8 x i32> %res
72 }
73 ; CHECK-LABEL: test2_x86_avx2_pblendd_256
74 ; CHECK-NOT: vpblendd
75 ; CHECK: ret
76
77
78 define <32 x i8> @test3_x86_avx2_pblendvb(<32 x i8> %a0, <32 x i8> %a1) {
79   %1 = bitcast <4 x i64> <i64 -1, i64 -1, i64 -1, i64 -1> to <32 x i8>
80   %res = call <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8> %a0, <32 x i8> %a1, <32 x i8> %1)
81   ret <32 x i8> %res
82 }
83 ; CHECK-LABEL: test3_x86_avx2_pblendvb
84 ; CHECK-NOT: vpblendvb
85 ; CHECK: ret
86
87
88 define <16 x i16> @test3_x86_avx2_pblendw(<16 x i16> %a0, <16 x i16> %a1) {
89   %res = call <16 x i16> @llvm.x86.avx2.pblendw(<16 x i16> %a0, <16 x i16> %a1, i32 -1)
90   ret <16 x i16> %res
91 }
92 ; CHECK-LABEL: test3_x86_avx2_pblendw
93 ; CHECK-NOT: vpblendw
94 ; CHECK: ret
95
96
97 define <4 x i32> @test3_x86_avx2_pblendd_128(<4 x i32> %a0, <4 x i32> %a1) {
98   %res = call <4 x i32> @llvm.x86.avx2.pblendd.128(<4 x i32> %a0, <4 x i32> %a1, i32 -1)
99   ret <4 x i32> %res
100 }
101 ; CHECK-LABEL: test3_x86_avx2_pblendd_128
102 ; CHECK-NOT: vpblendd
103 ; CHECK: ret
104
105
106 define <8 x i32> @test3_x86_avx2_pblendd_256(<8 x i32> %a0, <8 x i32> %a1) {
107   %res = call <8 x i32> @llvm.x86.avx2.pblendd.256(<8 x i32> %a0, <8 x i32> %a1, i32 -1)
108   ret <8 x i32> %res
109 }
110 ; CHECK-LABEL: test3_x86_avx2_pblendd_256
111 ; CHECK-NOT: vpblendd
112 ; CHECK: ret
113
114
115 declare <32 x i8> @llvm.x86.avx2.pblendvb(<32 x i8>, <32 x i8>, <32 x i8>)
116 declare <16 x i16> @llvm.x86.avx2.pblendw(<16 x i16>, <16 x i16>, i32)
117 declare <4 x i32> @llvm.x86.avx2.pblendd.128(<4 x i32>, <4 x i32>, i32)
118 declare <8 x i32> @llvm.x86.avx2.pblendd.256(<8 x i32>, <8 x i32>, i32)
119