Skip to content

Commit 5f7c385

Browse files
committed
[InstCombine] add tests for freeze of partial undef vector constants; NFC
1 parent f2d955a commit 5f7c385

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

llvm/test/Transforms/InstCombine/freeze.ll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ define void @or_select_multipleuses_logical(i32 %x, i1 %y) {
8787
ret void
8888
}
8989

90+
define <3 x i4> @partial_undef_vec() {
91+
; CHECK-LABEL: @partial_undef_vec(
92+
; CHECK-NEXT: [[F:%.*]] = freeze <3 x i4> <i4 poison, i4 1, i4 undef>
93+
; CHECK-NEXT: ret <3 x i4> [[F]]
94+
;
95+
%f = freeze <3 x i4> <i4 poison, i4 1, i4 undef>
96+
ret <3 x i4> %f
97+
}
98+
9099
; Move the freeze forward to prevent poison from spreading.
91100

92101
define i32 @early_freeze_test1(i32 %x, i32 %y) {
@@ -267,8 +276,8 @@ define i32 @propagate_drop_flags_mul(i32 %arg) {
267276
define i32 @propagate_drop_flags_udiv(i32 %arg) {
268277
; CHECK-LABEL: @propagate_drop_flags_udiv(
269278
; CHECK-NEXT: [[ARG_FR:%.*]] = freeze i32 [[ARG:%.*]]
270-
; CHECK-NEXT: [[V1:%.*]] = lshr i32 [[ARG_FR]], 1
271-
; CHECK-NEXT: ret i32 [[V1]]
279+
; CHECK-NEXT: [[V11:%.*]] = lshr i32 [[ARG_FR]], 1
280+
; CHECK-NEXT: ret i32 [[V11]]
272281
;
273282
%v1 = udiv exact i32 %arg, 2
274283
%v1.fr = freeze i32 %v1

llvm/test/Transforms/InstCombine/select.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,6 +2642,28 @@ define <2 x i8> @partial_cond_freeze_constant_true_val_vec(<2 x i8> %x) {
26422642
ret <2 x i8> %s
26432643
}
26442644

2645+
define <2 x i8> @partial_cond_freeze_constant_false_val_vec(<2 x i8> %x) {
2646+
; CHECK-LABEL: @partial_cond_freeze_constant_false_val_vec(
2647+
; CHECK-NEXT: [[COND_FR:%.*]] = freeze <2 x i1> <i1 true, i1 undef>
2648+
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> [[X:%.*]], <2 x i8> <i8 1, i8 2>
2649+
; CHECK-NEXT: ret <2 x i8> [[S]]
2650+
;
2651+
%cond.fr = freeze <2 x i1> <i1 true, i1 undef>
2652+
%s = select <2 x i1> %cond.fr, <2 x i8> %x, <2 x i8> <i8 1, i8 2>
2653+
ret <2 x i8> %s
2654+
}
2655+
2656+
define <2 x i8> @partial_cond_freeze_both_arms_constant_vec() {
2657+
; CHECK-LABEL: @partial_cond_freeze_both_arms_constant_vec(
2658+
; CHECK-NEXT: [[COND_FR:%.*]] = freeze <2 x i1> <i1 false, i1 undef>
2659+
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> <i8 1, i8 2>, <2 x i8> <i8 42, i8 43>
2660+
; CHECK-NEXT: ret <2 x i8> [[S]]
2661+
;
2662+
%cond.fr = freeze <2 x i1> <i1 false, i1 undef>
2663+
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> <i8 42, i8 43>
2664+
ret <2 x i8> %s
2665+
}
2666+
26452667
declare void @foo2(i8, i8)
26462668

26472669
define void @cond_freeze_multipleuses(i8 %x, i8 %y) {

0 commit comments

Comments
 (0)