Skip to content

Commit

Permalink
[InstCombine] add tests for select with frozen condition; NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
rotateright committed Apr 18, 2022
1 parent 359dbb0 commit 60de144
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions llvm/test/Transforms/InstCombine/select.ll
Expand Up @@ -2595,33 +2595,53 @@ define i8 @cond_freeze(i8 %x, i8 %y) {
ret i8 %s
}

define i8 @cond_freeze2(i8 %x, i8 %y) {
; CHECK-LABEL: @cond_freeze2(
define i8 @cond_freeze_constant_false_val(i8 %x) {
; CHECK-LABEL: @cond_freeze_constant_false_val(
; CHECK-NEXT: ret i8 1
;
%cond.fr = freeze i1 undef
%s = select i1 %cond.fr, i8 %x, i8 1
ret i8 %s
}

define i8 @cond_freeze3(i8 %x) {
; CHECK-LABEL: @cond_freeze3(
define i8 @cond_freeze_constant_true_val(i8 %x) {
; CHECK-LABEL: @cond_freeze_constant_true_val(
; CHECK-NEXT: ret i8 1
;
%cond.fr = freeze i1 undef
%s = select i1 %cond.fr, i8 1, i8 %x
ret i8 %s
}

define <2 x i8> @cond_freeze_vec(<2 x i8> %x) {
; CHECK-LABEL: @cond_freeze_vec(
define i8 @cond_freeze_both_arms_constant() {
; CHECK-LABEL: @cond_freeze_both_arms_constant(
; CHECK-NEXT: ret i8 3
;
%cond.fr = freeze i1 undef
%s = select i1 %cond.fr, i8 42, i8 3
ret i8 %s
}

define <2 x i8> @cond_freeze_constant_true_val_vec(<2 x i8> %x) {
; CHECK-LABEL: @cond_freeze_constant_true_val_vec(
; CHECK-NEXT: ret <2 x i8> <i8 1, i8 2>
;
%cond.fr = freeze <2 x i1> <i1 undef, i1 undef>
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> %x
ret <2 x i8> %s
}

define <2 x i8> @partial_cond_freeze_constant_true_val_vec(<2 x i8> %x) {
; CHECK-LABEL: @partial_cond_freeze_constant_true_val_vec(
; CHECK-NEXT: [[COND_FR:%.*]] = freeze <2 x i1> <i1 true, i1 undef>
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> <i8 1, i8 2>, <2 x i8> [[X:%.*]]
; CHECK-NEXT: ret <2 x i8> [[S]]
;
%cond.fr = freeze <2 x i1> <i1 true, i1 undef>
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> %x
ret <2 x i8> %s
}

declare void @foo2(i8, i8)

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

0 comments on commit 60de144

Please sign in to comment.