1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=CHECK %s
3 ; RUN: opt < %s -debugify -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=DBGINFO %s
5 define i32 @test1(i1 %C) {
8 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C:%.*]], i32 1, i32 0
9 ; CHECK-NEXT: ret i32 [[DOT]]
11 ; DBGINFO-LABEL: @test1(
12 ; DBGINFO-NEXT: entry:
13 ; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG11:![0-9]+]]
14 ; DBGINFO-NEXT: [[DOT:%.*]] = select i1 [[C:%.*]], i32 1, i32 0
15 ; DBGINFO-NEXT: ret i32 [[DOT]], !dbg [[DBG12:![0-9]+]]
18 br i1 %C, label %T, label %F
25 define void @test2(i1 %C) {
26 ; CHECK-LABEL: @test2(
27 ; CHECK-NEXT: common.ret:
28 ; CHECK-NEXT: ret void
30 ; DBGINFO-LABEL: @test2(
31 ; DBGINFO-NEXT: common.ret:
32 ; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META15:![0-9]+]], metadata !DIExpression()), !dbg [[DBG16:![0-9]+]]
33 ; DBGINFO-NEXT: ret void, !dbg [[DBG17:![0-9]+]]
35 br i1 %C, label %T, label %F
42 declare void @sideeffect0()
43 declare void @sideeffect1()
44 declare void @sideeffect2()
46 define i32 @test3(i1 %C0, i1 %C1, i32 %v0, i32 %v1, i32 %v2) {
47 ; CHECK-LABEL: @test3(
49 ; CHECK-NEXT: call void @sideeffect0()
50 ; CHECK-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]]
52 ; CHECK-NEXT: [[R:%.*]] = phi i32 [ [[V2:%.*]], [[F]] ], [ [[SPEC_SELECT:%.*]], [[T]] ]
53 ; CHECK-NEXT: ret i32 [[R]]
55 ; CHECK-NEXT: call void @sideeffect1()
56 ; CHECK-NEXT: [[SPEC_SELECT]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]]
57 ; CHECK-NEXT: br label [[END:%.*]]
59 ; CHECK-NEXT: call void @sideeffect2()
60 ; CHECK-NEXT: br label [[END]]
62 ; DBGINFO-LABEL: @test3(
63 ; DBGINFO-NEXT: entry:
64 ; DBGINFO-NEXT: call void @sideeffect0(), !dbg [[DBG21:![0-9]+]]
65 ; DBGINFO-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]], !dbg [[DBG22:![0-9]+]]
67 ; DBGINFO-NEXT: [[R:%.*]] = phi i32 [ [[V2:%.*]], [[F]] ], [ [[SPEC_SELECT:%.*]], [[T]] ], !dbg [[DBG23:![0-9]+]]
68 ; DBGINFO-NEXT: call void @llvm.dbg.value(metadata i32 [[R]], metadata [[META20:![0-9]+]], metadata !DIExpression()), !dbg [[DBG23]]
69 ; DBGINFO-NEXT: ret i32 [[R]], !dbg [[DBG24:![0-9]+]]
71 ; DBGINFO-NEXT: call void @sideeffect1(), !dbg [[DBG25:![0-9]+]]
72 ; DBGINFO-NEXT: [[SPEC_SELECT]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]], !dbg [[DBG26:![0-9]+]]
73 ; DBGINFO-NEXT: br label [[END:%.*]], !dbg [[DBG26]]
75 ; DBGINFO-NEXT: call void @sideeffect2(), !dbg [[DBG27:![0-9]+]]
76 ; DBGINFO-NEXT: br label [[END]], !dbg [[DBG28:![0-9]+]]
79 call void @sideeffect0()
80 br i1 %C0, label %T, label %F
83 ; empty block with single predecessor
87 %r = phi i32 [ %v0, %T.cont ], [ %v1, %T ], [ %v2, %F ]
92 call void @sideeffect1()
93 br i1 %C1, label %T.cont, label %end
96 call void @sideeffect2()