Skip to content

Commit 60de144

Browse files
committed
[InstCombine] add tests for select with frozen condition; NFC
1 parent 359dbb0 commit 60de144

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

llvm/test/Transforms/InstCombine/select.ll

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,33 +2595,53 @@ define i8 @cond_freeze(i8 %x, i8 %y) {
25952595
ret i8 %s
25962596
}
25972597

2598-
define i8 @cond_freeze2(i8 %x, i8 %y) {
2599-
; CHECK-LABEL: @cond_freeze2(
2598+
define i8 @cond_freeze_constant_false_val(i8 %x) {
2599+
; CHECK-LABEL: @cond_freeze_constant_false_val(
26002600
; CHECK-NEXT: ret i8 1
26012601
;
26022602
%cond.fr = freeze i1 undef
26032603
%s = select i1 %cond.fr, i8 %x, i8 1
26042604
ret i8 %s
26052605
}
26062606

2607-
define i8 @cond_freeze3(i8 %x) {
2608-
; CHECK-LABEL: @cond_freeze3(
2607+
define i8 @cond_freeze_constant_true_val(i8 %x) {
2608+
; CHECK-LABEL: @cond_freeze_constant_true_val(
26092609
; CHECK-NEXT: ret i8 1
26102610
;
26112611
%cond.fr = freeze i1 undef
26122612
%s = select i1 %cond.fr, i8 1, i8 %x
26132613
ret i8 %s
26142614
}
26152615

2616-
define <2 x i8> @cond_freeze_vec(<2 x i8> %x) {
2617-
; CHECK-LABEL: @cond_freeze_vec(
2616+
define i8 @cond_freeze_both_arms_constant() {
2617+
; CHECK-LABEL: @cond_freeze_both_arms_constant(
2618+
; CHECK-NEXT: ret i8 3
2619+
;
2620+
%cond.fr = freeze i1 undef
2621+
%s = select i1 %cond.fr, i8 42, i8 3
2622+
ret i8 %s
2623+
}
2624+
2625+
define <2 x i8> @cond_freeze_constant_true_val_vec(<2 x i8> %x) {
2626+
; CHECK-LABEL: @cond_freeze_constant_true_val_vec(
26182627
; CHECK-NEXT: ret <2 x i8> <i8 1, i8 2>
26192628
;
26202629
%cond.fr = freeze <2 x i1> <i1 undef, i1 undef>
26212630
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> %x
26222631
ret <2 x i8> %s
26232632
}
26242633

2634+
define <2 x i8> @partial_cond_freeze_constant_true_val_vec(<2 x i8> %x) {
2635+
; CHECK-LABEL: @partial_cond_freeze_constant_true_val_vec(
2636+
; CHECK-NEXT: [[COND_FR:%.*]] = freeze <2 x i1> <i1 true, i1 undef>
2637+
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> <i8 1, i8 2>, <2 x i8> [[X:%.*]]
2638+
; CHECK-NEXT: ret <2 x i8> [[S]]
2639+
;
2640+
%cond.fr = freeze <2 x i1> <i1 true, i1 undef>
2641+
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> %x
2642+
ret <2 x i8> %s
2643+
}
2644+
26252645
declare void @foo2(i8, i8)
26262646

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

0 commit comments

Comments
 (0)