1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64 -S | FileCheck %s --check-prefixes=SSE2
3 ; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v2 -S | FileCheck %s --check-prefixes=SSE42
4 ; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v3 -S | FileCheck %s --check-prefixes=AVX
5 ; RUN: opt < %s -passes=slp-vectorizer -mtriple=x86_64-- -mcpu=x86-64-v4 -S | FileCheck %s --check-prefixes=AVX
8 ; typedef int v4si __attribute__ ((vector_size (16)));
10 ; inline int reduce_and4(int acc, v4si v1, v4si v2, v4si v3, v4si v4) {
11 ; acc &= v1[0] & v1[1] & v1[2] & v1[3];
12 ; acc &= v2[0] & v2[1] & v2[2] & v2[3];
13 ; acc &= v3[0] & v3[1] & v3[2] & v3[3];
14 ; acc &= v4[0] & v4[1] & v4[2] & v4[3];
18 define i32 @reduce_and4(i32 %acc, <4 x i32> %v1, <4 x i32> %v2, <4 x i32> %v3, <4 x i32> %v4) {
19 ; SSE2-LABEL: @reduce_and4(
21 ; SSE2-NEXT: [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
22 ; SSE2-NEXT: [[TMP1:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP0]])
23 ; SSE2-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
24 ; SSE2-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP2]])
25 ; SSE2-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP1]], [[TMP3]]
26 ; SSE2-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
27 ; SSE2-NEXT: ret i32 [[OP_RDX1]]
29 ; SSE42-LABEL: @reduce_and4(
31 ; SSE42-NEXT: [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
32 ; SSE42-NEXT: [[TMP1:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP0]])
33 ; SSE42-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
34 ; SSE42-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP2]])
35 ; SSE42-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP1]], [[TMP3]]
36 ; SSE42-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
37 ; SSE42-NEXT: ret i32 [[OP_RDX1]]
39 ; AVX-LABEL: @reduce_and4(
41 ; AVX-NEXT: [[TMP0:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
42 ; AVX-NEXT: [[TMP1:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP0]])
43 ; AVX-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 1, i32 0, i32 2, i32 3, i32 5, i32 4, i32 6, i32 7>
44 ; AVX-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP2]])
45 ; AVX-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP1]], [[TMP3]]
46 ; AVX-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
47 ; AVX-NEXT: ret i32 [[OP_RDX1]]
50 %vecext = extractelement <4 x i32> %v1, i64 0
51 %vecext1 = extractelement <4 x i32> %v1, i64 1
52 %vecext2 = extractelement <4 x i32> %v1, i64 2
53 %vecext4 = extractelement <4 x i32> %v1, i64 3
54 %vecext7 = extractelement <4 x i32> %v2, i64 0
55 %vecext8 = extractelement <4 x i32> %v2, i64 1
56 %vecext10 = extractelement <4 x i32> %v2, i64 2
57 %vecext12 = extractelement <4 x i32> %v2, i64 3
58 %vecext15 = extractelement <4 x i32> %v3, i64 0
59 %vecext16 = extractelement <4 x i32> %v3, i64 1
60 %vecext18 = extractelement <4 x i32> %v3, i64 2
61 %vecext20 = extractelement <4 x i32> %v3, i64 3
62 %vecext23 = extractelement <4 x i32> %v4, i64 0
63 %vecext24 = extractelement <4 x i32> %v4, i64 1
64 %vecext26 = extractelement <4 x i32> %v4, i64 2
65 %vecext28 = extractelement <4 x i32> %v4, i64 3
66 %and25 = and i32 %vecext1, %acc
67 %and27 = and i32 %and25, %vecext
68 %and29 = and i32 %and27, %vecext2
69 %and17 = and i32 %and29, %vecext4
70 %and19 = and i32 %and17, %vecext8
71 %and21 = and i32 %and19, %vecext7
72 %and9 = and i32 %and21, %vecext10
73 %and11 = and i32 %and9, %vecext12
74 %and13 = and i32 %and11, %vecext16
75 %and = and i32 %and13, %vecext15
76 %and3 = and i32 %and, %vecext18
77 %and5 = and i32 %and3, %vecext20
78 %and6 = and i32 %and5, %vecext24
79 %and14 = and i32 %and6, %vecext23
80 %and22 = and i32 %and14, %vecext26
81 %and30 = and i32 %and22, %vecext28
85 ; int reduce_and4_transpose(int acc, v4si v1, v4si v2, v4si v3, v4si v4) {
86 ; acc &= v1[0] & v2[0] & v3[0] & v4[0];
87 ; acc &= v1[1] & v2[1] & v3[1] & v4[1];
88 ; acc &= v1[2] & v2[2] & v3[2] & v4[2];
89 ; acc &= v1[3] & v2[3] & v3[3] & v4[3];
93 define i32 @reduce_and4_transpose(i32 %acc, <4 x i32> %v1, <4 x i32> %v2, <4 x i32> %v3, <4 x i32> %v4) {
94 ; SSE2-LABEL: @reduce_and4_transpose(
95 ; SSE2-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
96 ; SSE2-NEXT: [[TMP2:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP1]])
97 ; SSE2-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
98 ; SSE2-NEXT: [[TMP4:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP3]])
99 ; SSE2-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP2]], [[TMP4]]
100 ; SSE2-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
101 ; SSE2-NEXT: ret i32 [[OP_RDX1]]
103 ; SSE42-LABEL: @reduce_and4_transpose(
104 ; SSE42-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
105 ; SSE42-NEXT: [[TMP2:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP1]])
106 ; SSE42-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
107 ; SSE42-NEXT: [[TMP4:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP3]])
108 ; SSE42-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP2]], [[TMP4]]
109 ; SSE42-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
110 ; SSE42-NEXT: ret i32 [[OP_RDX1]]
112 ; AVX-LABEL: @reduce_and4_transpose(
113 ; AVX-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[V4:%.*]], <4 x i32> [[V3:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
114 ; AVX-NEXT: [[TMP2:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP1]])
115 ; AVX-NEXT: [[TMP3:%.*]] = shufflevector <4 x i32> [[V2:%.*]], <4 x i32> [[V1:%.*]], <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>
116 ; AVX-NEXT: [[TMP4:%.*]] = call i32 @llvm.vector.reduce.and.v8i32(<8 x i32> [[TMP3]])
117 ; AVX-NEXT: [[OP_RDX:%.*]] = and i32 [[TMP2]], [[TMP4]]
118 ; AVX-NEXT: [[OP_RDX1:%.*]] = and i32 [[OP_RDX]], [[ACC:%.*]]
119 ; AVX-NEXT: ret i32 [[OP_RDX1]]
121 %vecext = extractelement <4 x i32> %v1, i64 0
122 %vecext1 = extractelement <4 x i32> %v2, i64 0
123 %vecext2 = extractelement <4 x i32> %v3, i64 0
124 %vecext4 = extractelement <4 x i32> %v4, i64 0
125 %vecext7 = extractelement <4 x i32> %v1, i64 1
126 %vecext8 = extractelement <4 x i32> %v2, i64 1
127 %vecext10 = extractelement <4 x i32> %v3, i64 1
128 %vecext12 = extractelement <4 x i32> %v4, i64 1
129 %vecext15 = extractelement <4 x i32> %v1, i64 2
130 %vecext16 = extractelement <4 x i32> %v2, i64 2
131 %vecext18 = extractelement <4 x i32> %v3, i64 2
132 %vecext20 = extractelement <4 x i32> %v4, i64 2
133 %vecext23 = extractelement <4 x i32> %v1, i64 3
134 %vecext24 = extractelement <4 x i32> %v2, i64 3
135 %vecext26 = extractelement <4 x i32> %v3, i64 3
136 %vecext28 = extractelement <4 x i32> %v4, i64 3
137 %and = and i32 %vecext23, %acc
138 %and3 = and i32 %and, %vecext15
139 %and5 = and i32 %and3, %vecext7
140 %and6 = and i32 %and5, %vecext
141 %and9 = and i32 %and6, %vecext24
142 %and11 = and i32 %and9, %vecext16
143 %and13 = and i32 %and11, %vecext8
144 %and14 = and i32 %and13, %vecext1
145 %and17 = and i32 %and14, %vecext26
146 %and19 = and i32 %and17, %vecext18
147 %and21 = and i32 %and19, %vecext10
148 %and22 = and i32 %and21, %vecext2
149 %and25 = and i32 %and22, %vecext28
150 %and27 = and i32 %and25, %vecext20
151 %and29 = and i32 %and27, %vecext12
152 %and30 = and i32 %and29, %vecext4