Skip to content

Commit 276a6b8

Browse files
committed
[InstCombine] add tests for cmp with splat operand and splat constant; NFC
See PR44588: https://bugs.llvm.org/show_bug.cgi?id=44588
1 parent e7d5a8d commit 276a6b8

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

llvm/test/Transforms/InstCombine/icmp-vec.ll

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,81 @@ define <2 x i1> @same_shuffle_inputs_icmp_extra_use3(<4 x i8> %x, <4 x i8> %y) {
289289
ret <2 x i1> %cmp
290290
}
291291

292+
define <4 x i1> @splat_icmp(<4 x i8> %x) {
293+
; CHECK-LABEL: @splat_icmp(
294+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
295+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], <i8 42, i8 42, i8 42, i8 42>
296+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
297+
;
298+
%splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
299+
%cmp = icmp sgt <4 x i8> %splatx, <i8 42, i8 42, i8 42, i8 42>
300+
ret <4 x i1> %cmp
301+
}
302+
303+
define <4 x i1> @splat_icmp_undef(<4 x i8> %x) {
304+
; CHECK-LABEL: @splat_icmp_undef(
305+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 2, i32 undef, i32 undef, i32 2>
306+
; CHECK-NEXT: [[CMP:%.*]] = icmp ult <4 x i8> [[SPLATX]], <i8 undef, i8 42, i8 undef, i8 42>
307+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
308+
;
309+
%splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 2, i32 undef, i32 undef, i32 2>
310+
%cmp = icmp ult <4 x i8> %splatx, <i8 undef, i8 42, i8 undef, i8 42>
311+
ret <4 x i1> %cmp
312+
}
313+
314+
define <4 x i1> @splat_icmp_larger_size(<2 x i8> %x) {
315+
; CHECK-LABEL: @splat_icmp_larger_size(
316+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> <i32 1, i32 undef, i32 1, i32 undef>
317+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq <4 x i8> [[SPLATX]], <i8 42, i8 42, i8 undef, i8 42>
318+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
319+
;
320+
%splatx = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> <i32 1, i32 undef, i32 1, i32 undef>
321+
%cmp = icmp eq <4 x i8> %splatx, <i8 42, i8 42, i8 undef, i8 42>
322+
ret <4 x i1> %cmp
323+
}
324+
325+
define <4 x i1> @splat_fcmp_smaller_size(<5 x float> %x) {
326+
; CHECK-LABEL: @splat_fcmp_smaller_size(
327+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <5 x float> [[X:%.*]], <5 x float> undef, <4 x i32> <i32 1, i32 undef, i32 1, i32 undef>
328+
; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq <4 x float> [[SPLATX]], <float 4.200000e+01, float 4.200000e+01, float undef, float 4.200000e+01>
329+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
330+
;
331+
%splatx = shufflevector <5 x float> %x, <5 x float> undef, <4 x i32> <i32 1, i32 undef, i32 1, i32 undef>
332+
%cmp = fcmp oeq <4 x float> %splatx, <float 42.0, float 42.0, float undef, float 42.0>
333+
ret <4 x i1> %cmp
334+
}
335+
336+
define <4 x i1> @splat_icmp_extra_use(<4 x i8> %x) {
337+
; CHECK-LABEL: @splat_icmp_extra_use(
338+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
339+
; CHECK-NEXT: call void @use_v4i8(<4 x i8> [[SPLATX]])
340+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], <i8 42, i8 42, i8 42, i8 42>
341+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
342+
;
343+
%splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
344+
call void @use_v4i8(<4 x i8> %splatx)
345+
%cmp = icmp sgt <4 x i8> %splatx, <i8 42, i8 42, i8 42, i8 42>
346+
ret <4 x i1> %cmp
347+
}
348+
349+
define <4 x i1> @not_splat_icmp(<4 x i8> %x) {
350+
; CHECK-LABEL: @not_splat_icmp(
351+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 3, i32 2, i32 3, i32 3>
352+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], <i8 42, i8 42, i8 42, i8 42>
353+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
354+
;
355+
%splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 3, i32 2, i32 3, i32 3>
356+
%cmp = icmp sgt <4 x i8> %splatx, <i8 42, i8 42, i8 42, i8 42>
357+
ret <4 x i1> %cmp
358+
}
359+
360+
define <4 x i1> @not_splat_icmp2(<4 x i8> %x) {
361+
; CHECK-LABEL: @not_splat_icmp2(
362+
; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> undef, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
363+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <4 x i8> [[SPLATX]], <i8 43, i8 42, i8 42, i8 42>
364+
; CHECK-NEXT: ret <4 x i1> [[CMP]]
365+
;
366+
%splatx = shufflevector <4 x i8> %x, <4 x i8> undef, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
367+
%cmp = icmp sgt <4 x i8> %splatx, <i8 43, i8 42, i8 42, i8 42>
368+
ret <4 x i1> %cmp
369+
}

0 commit comments

Comments
 (0)