@@ -107,6 +107,24 @@ TEST_F(VectorUtilsTest, isSplatValue_00) {
107
107
EXPECT_TRUE (isSplatValue (A));
108
108
}
109
109
110
+ TEST_F (VectorUtilsTest, isSplatValue_00_index0) {
111
+ parseAssembly (
112
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
113
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> zeroinitializer\n "
114
+ " ret <2 x i8> %A\n "
115
+ " }\n " );
116
+ EXPECT_TRUE (isSplatValue (A, 0 ));
117
+ }
118
+
119
+ TEST_F (VectorUtilsTest, isSplatValue_00_index1) {
120
+ parseAssembly (
121
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
122
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> zeroinitializer\n "
123
+ " ret <2 x i8> %A\n "
124
+ " }\n " );
125
+ EXPECT_FALSE (isSplatValue (A, 1 ));
126
+ }
127
+
110
128
TEST_F (VectorUtilsTest, isSplatValue_11) {
111
129
parseAssembly (
112
130
" define <2 x i8> @test(<2 x i8> %x) {\n "
@@ -116,6 +134,24 @@ TEST_F(VectorUtilsTest, isSplatValue_11) {
116
134
EXPECT_TRUE (isSplatValue (A));
117
135
}
118
136
137
+ TEST_F (VectorUtilsTest, isSplatValue_11_index0) {
138
+ parseAssembly (
139
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
140
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
141
+ " ret <2 x i8> %A\n "
142
+ " }\n " );
143
+ EXPECT_FALSE (isSplatValue (A, 0 ));
144
+ }
145
+
146
+ TEST_F (VectorUtilsTest, isSplatValue_11_index1) {
147
+ parseAssembly (
148
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
149
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
150
+ " ret <2 x i8> %A\n "
151
+ " }\n " );
152
+ EXPECT_TRUE (isSplatValue (A, 1 ));
153
+ }
154
+
119
155
TEST_F (VectorUtilsTest, isSplatValue_01) {
120
156
parseAssembly (
121
157
" define <2 x i8> @test(<2 x i8> %x) {\n "
@@ -125,7 +161,25 @@ TEST_F(VectorUtilsTest, isSplatValue_01) {
125
161
EXPECT_FALSE (isSplatValue (A));
126
162
}
127
163
128
- // FIXME: Constant (mask) splat analysis does not allow undef elements.
164
+ TEST_F (VectorUtilsTest, isSplatValue_01_index0) {
165
+ parseAssembly (
166
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
167
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 1>\n "
168
+ " ret <2 x i8> %A\n "
169
+ " }\n " );
170
+ EXPECT_FALSE (isSplatValue (A, 0 ));
171
+ }
172
+
173
+ TEST_F (VectorUtilsTest, isSplatValue_01_index1) {
174
+ parseAssembly (
175
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
176
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 1>\n "
177
+ " ret <2 x i8> %A\n "
178
+ " }\n " );
179
+ EXPECT_FALSE (isSplatValue (A, 1 ));
180
+ }
181
+
182
+ // FIXME: Allow undef matching with Constant (mask) splat analysis.
129
183
130
184
TEST_F (VectorUtilsTest, isSplatValue_0u) {
131
185
parseAssembly (
@@ -136,6 +190,26 @@ TEST_F(VectorUtilsTest, isSplatValue_0u) {
136
190
EXPECT_FALSE (isSplatValue (A));
137
191
}
138
192
193
+ // FIXME: Allow undef matching with Constant (mask) splat analysis.
194
+
195
+ TEST_F (VectorUtilsTest, isSplatValue_0u_index0) {
196
+ parseAssembly (
197
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
198
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 undef>\n "
199
+ " ret <2 x i8> %A\n "
200
+ " }\n " );
201
+ EXPECT_FALSE (isSplatValue (A, 0 ));
202
+ }
203
+
204
+ TEST_F (VectorUtilsTest, isSplatValue_0u_index1) {
205
+ parseAssembly (
206
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
207
+ " %A = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 undef>\n "
208
+ " ret <2 x i8> %A\n "
209
+ " }\n " );
210
+ EXPECT_FALSE (isSplatValue (A, 1 ));
211
+ }
212
+
139
213
TEST_F (VectorUtilsTest, isSplatValue_Binop) {
140
214
parseAssembly (
141
215
" define <2 x i8> @test(<2 x i8> %x) {\n "
@@ -147,6 +221,28 @@ TEST_F(VectorUtilsTest, isSplatValue_Binop) {
147
221
EXPECT_TRUE (isSplatValue (A));
148
222
}
149
223
224
+ TEST_F (VectorUtilsTest, isSplatValue_Binop_index0) {
225
+ parseAssembly (
226
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
227
+ " %v0 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 0>\n "
228
+ " %v1 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
229
+ " %A = udiv <2 x i8> %v0, %v1\n "
230
+ " ret <2 x i8> %A\n "
231
+ " }\n " );
232
+ EXPECT_FALSE (isSplatValue (A, 0 ));
233
+ }
234
+
235
+ TEST_F (VectorUtilsTest, isSplatValue_Binop_index1) {
236
+ parseAssembly (
237
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
238
+ " %v0 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 0, i32 0>\n "
239
+ " %v1 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
240
+ " %A = udiv <2 x i8> %v0, %v1\n "
241
+ " ret <2 x i8> %A\n "
242
+ " }\n " );
243
+ EXPECT_FALSE (isSplatValue (A, 1 ));
244
+ }
245
+
150
246
TEST_F (VectorUtilsTest, isSplatValue_Binop_ConstantOp0) {
151
247
parseAssembly (
152
248
" define <2 x i8> @test(<2 x i8> %x) {\n "
@@ -157,6 +253,26 @@ TEST_F(VectorUtilsTest, isSplatValue_Binop_ConstantOp0) {
157
253
EXPECT_TRUE (isSplatValue (A));
158
254
}
159
255
256
+ TEST_F (VectorUtilsTest, isSplatValue_Binop_ConstantOp0_index0) {
257
+ parseAssembly (
258
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
259
+ " %v1 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
260
+ " %A = ashr <2 x i8> <i8 42, i8 42>, %v1\n "
261
+ " ret <2 x i8> %A\n "
262
+ " }\n " );
263
+ EXPECT_FALSE (isSplatValue (A, 0 ));
264
+ }
265
+
266
+ TEST_F (VectorUtilsTest, isSplatValue_Binop_ConstantOp0_index1) {
267
+ parseAssembly (
268
+ " define <2 x i8> @test(<2 x i8> %x) {\n "
269
+ " %v1 = shufflevector <2 x i8> %x, <2 x i8> undef, <2 x i32> <i32 1, i32 1>\n "
270
+ " %A = ashr <2 x i8> <i8 42, i8 42>, %v1\n "
271
+ " ret <2 x i8> %A\n "
272
+ " }\n " );
273
+ EXPECT_TRUE (isSplatValue (A, 1 ));
274
+ }
275
+
160
276
TEST_F (VectorUtilsTest, isSplatValue_Binop_Not_Op0) {
161
277
parseAssembly (
162
278
" define <2 x i8> @test(<2 x i8> %x) {\n "
0 commit comments