; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt %loadexampleirtransforms -passes=tut-simplifycfg -tut-simplifycfg-version=v1 -S < %s | FileCheck %s
; RUN: opt %loadexampleirtransforms -passes=tut-simplifycfg -tut-simplifycfg-version=v2 -S < %s | FileCheck %s
; RUN: opt %loadexampleirtransforms -passes=tut-simplifycfg -tut-simplifycfg-version=v3 -S < %s | FileCheck %s
define i32 @phi_cond_branch_eliminated() {
; CHECK-LABEL: @phi_cond_branch_eliminated(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 20
;
entry:
br i1 true, label %bb.2, label %bb.3
bb.2:
br label %bb.3
bb.3:
%ret = phi i32 [ 10, %entry ], [ 20, %bb.2 ]
ret i32 %ret
}
define i32 @phi_removed() {
; CHECK-LABEL: @phi_removed(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[BB_3:%.*]]
; CHECK: bb.3:
; CHECK-NEXT: ret i32 0
;
entry:
br i1 false, label %bb.2, label %bb.3
bb.2:
%pv = phi i32 [ 10, %entry ]
br label %bb.3
bb.3:
ret i32 0
}
define i32 @phi_in_dead_region() {
; CHECK-LABEL: @phi_in_dead_region(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 1
;
entry:
ret i32 1
bb.1:
br i1 true, label %bb.2, label %bb.3
bb.2:
br label %bb.3
bb.3:
%ret = phi i32 [ 10, %bb.1 ], [ 20, %bb.2 ]
ret i32 %ret
}
define i32 @phi_in_mergable_blocks() {
; CHECK-LABEL: @phi_in_mergable_blocks(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret i32 10
;
entry:
br label %bb.1
bb.1:
%pv = phi i32 [ 10, %entry ]
ret i32 %pv
}