Skip to content

Commit

Permalink
[InstCombine][Test] Test for fix of replacing select with Phis when b…
Browse files Browse the repository at this point in the history
…ranch has the same labels

An additional test that allows to check the correctness of handling the case of the same
branch labels in the dominator when trying to replace select with phi-node.

Patch By: Kirill Polushin
Differential Revision: https://reviews.llvm.org/D84006
Reviewed By: mkazantsev
  • Loading branch information
xortator committed Jul 17, 2020
1 parent bb160e7 commit df6e185
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions llvm/test/Transforms/InstCombine/select.ll
Expand Up @@ -2000,6 +2000,21 @@ merge:
ret i32 %s
}

define i32 @select_dominating_cond_same_labels(i1 %cond) {
; CHECK-LABEL: @select_dominating_cond_same_labels(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 false, label [[EXIT:%.*]], label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: [[RESULT:%.*]] = select i1 [[COND:%.*]], i32 123, i32 456
; CHECK-NEXT: ret i32 [[RESULT]]
;
entry:
%result = select i1 %cond, i32 123, i32 456
br i1 %cond, label %exit, label %exit
exit:
ret i32 %result
}

define i32 @select_phi_same_condition(i1 %cond, i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: @select_phi_same_condition(
; CHECK-NEXT: entry:
Expand Down

0 comments on commit df6e185

Please sign in to comment.