blob: 7d762286c8f308e98ab2210463de1996f648504e [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5
; RUN: opt -passes='simplifycfg<hoist-common-insts;sink-common-insts>' -S < %s | FileCheck %s
; Hoisting or sinking replaces the instructions on both paths with a single
; instruction, which requests the PC sections of either of them.
define void @sink_first_only(i1 %c, ptr %p) {
; CHECK-LABEL: define void @sink_first_only(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i8 1, i8 2
; CHECK-NEXT: store i8 [[DOT]], ptr [[P]], align 1, !pcsections [[META0:![0-9]+]]
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1, !pcsections !0
br label %end
b:
store i8 2, ptr %p, align 1
br label %end
end:
ret void
}
define void @sink_second_only(i1 %c, ptr %p) {
; CHECK-LABEL: define void @sink_second_only(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i8 1, i8 2
; CHECK-NEXT: store i8 [[DOT]], ptr [[P]], align 1, !pcsections [[META0]]
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1
br label %end
b:
store i8 2, ptr %p, align 1, !pcsections !0
br label %end
end:
ret void
}
define void @sink_both(i1 %c, ptr %p) {
; CHECK-LABEL: define void @sink_both(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i8 1, i8 2
; CHECK-NEXT: store i8 [[DOT]], ptr [[P]], align 1, !pcsections [[META2:![0-9]+]]
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1, !pcsections !0
br label %end
b:
store i8 2, ptr %p, align 1, !pcsections !2
br label %end
end:
ret void
}
; A request that both make is not duplicated.
define void @sink_shared_request(i1 %c, ptr %p) {
; CHECK-LABEL: define void @sink_shared_request(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i8 1, i8 2
; CHECK-NEXT: store i8 [[DOT]], ptr [[P]], align 1, !pcsections [[META4:![0-9]+]]
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1, !pcsections !4
br label %end
b:
store i8 2, ptr %p, align 1, !pcsections !0
br label %end
end:
ret void
}
define void @sink_neither(i1 %c, ptr %p) {
; CHECK-LABEL: define void @sink_neither(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C]], i8 1, i8 2
; CHECK-NEXT: store i8 [[DOT]], ptr [[P]], align 1
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1
br label %end
b:
store i8 2, ptr %p, align 1
br label %end
end:
ret void
}
define void @hoist_both(i1 %c, ptr %p) {
; CHECK-LABEL: define void @hoist_both(
; CHECK-SAME: i1 [[C:%.*]], ptr [[P:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: store i8 1, ptr [[P]], align 1, !pcsections [[META5:![0-9]+]]
; CHECK-NEXT: ret void
;
entry:
br i1 %c, label %a, label %b
a:
store i8 1, ptr %p, align 1, !pcsections !0
br label %end
b:
store i8 1, ptr %p, align 1, !pcsections !2
br label %end
end:
ret void
}
!0 = !{!"section", !1}
!1 = !{i32 1}
!2 = !{!"section", !3}
!3 = !{i32 2}
!4 = !{!"other", !3, !"section", !1}
;.
; CHECK: [[META0]] = !{!"section", [[META1:![0-9]+]]}
; CHECK: [[META1]] = !{i32 1}
; CHECK: [[META2]] = !{!"section", [[META3:![0-9]+]], !"section", [[META1]]}
; CHECK: [[META3]] = !{i32 2}
; CHECK: [[META4]] = !{!"section", [[META1]], !"other", [[META3]]}
; CHECK: [[META5]] = !{!"section", [[META1]], !"section", [[META3]]}
;.