1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=CHECK %s
3 ; RUN: opt < %s -passes=debugify,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck --check-prefixes=DBGINFO %s
5 ; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S --try-experimental-debuginfo-iterators | FileCheck --check-prefixes=CHECK %s
6 ; RUN: opt < %s -passes=debugify,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S --try-experimental-debuginfo-iterators | FileCheck --check-prefixes=DBGINFO %s
8 define i32 @test1(i1 %C) {
11 ; CHECK-NEXT: [[DOT:%.*]] = select i1 [[C:%.*]], i32 1, i32 0
12 ; CHECK-NEXT: ret i32 [[DOT]]
14 ; DBGINFO-LABEL: @test1(
15 ; DBGINFO-NEXT: entry:
16 ; DBGINFO-NEXT: #dbg_value(i32 0, [[META9:![0-9]+]], !DIExpression(), [[META11:![0-9]+]])
17 ; DBGINFO-NEXT: [[DOT:%.*]] = select i1 [[C:%.*]], i32 1, i32 0
18 ; DBGINFO-NEXT: ret i32 [[DOT]], !dbg [[DBG12:![0-9]+]]
21 br i1 %C, label %T, label %F
28 define void @test2(i1 %C) {
29 ; CHECK-LABEL: @test2(
30 ; CHECK-NEXT: common.ret:
31 ; CHECK-NEXT: ret void
33 ; DBGINFO-LABEL: @test2(
34 ; DBGINFO-NEXT: common.ret:
35 ; DBGINFO-NEXT: #dbg_value(i32 0, [[META15:![0-9]+]], !DIExpression(), [[META16:![0-9]+]])
36 ; DBGINFO-NEXT: ret void, !dbg [[DBG17:![0-9]+]]
38 br i1 %C, label %T, label %F
45 declare void @sideeffect0()
46 declare void @sideeffect1()
47 declare void @sideeffect2()
49 define i32 @test3(i1 %C0, i1 %C1, i32 %v0, i32 %v1, i32 %v2) {
50 ; CHECK-LABEL: @test3(
52 ; CHECK-NEXT: call void @sideeffect0()
53 ; CHECK-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]]
55 ; CHECK-NEXT: [[R:%.*]] = phi i32 [ [[V2:%.*]], [[F]] ], [ [[SPEC_SELECT:%.*]], [[T]] ]
56 ; CHECK-NEXT: ret i32 [[R]]
58 ; CHECK-NEXT: call void @sideeffect1()
59 ; CHECK-NEXT: [[SPEC_SELECT]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]]
60 ; CHECK-NEXT: br label [[END:%.*]]
62 ; CHECK-NEXT: call void @sideeffect2()
63 ; CHECK-NEXT: br label [[END]]
65 ; DBGINFO-LABEL: @test3(
66 ; DBGINFO-NEXT: entry:
67 ; DBGINFO-NEXT: call void @sideeffect0(), !dbg [[DBG21:![0-9]+]]
68 ; DBGINFO-NEXT: br i1 [[C0:%.*]], label [[T:%.*]], label [[F:%.*]], !dbg [[DBG22:![0-9]+]]
70 ; DBGINFO-NEXT: [[R:%.*]] = phi i32 [ [[V2:%.*]], [[F]] ], [ [[SPEC_SELECT:%.*]], [[T]] ], !dbg [[DBG23:![0-9]+]]
71 ; DBGINFO-NEXT: #dbg_value(i32 [[R]], [[META20:![0-9]+]], !DIExpression(), [[DBG23]])
72 ; DBGINFO-NEXT: ret i32 [[R]], !dbg [[DBG24:![0-9]+]]
74 ; DBGINFO-NEXT: call void @sideeffect1(), !dbg [[DBG25:![0-9]+]]
75 ; DBGINFO-NEXT: [[SPEC_SELECT]] = select i1 [[C1:%.*]], i32 [[V0:%.*]], i32 [[V1:%.*]], !dbg [[DBG26:![0-9]+]]
76 ; DBGINFO-NEXT: br label [[END:%.*]], !dbg [[DBG26]]
78 ; DBGINFO-NEXT: call void @sideeffect2(), !dbg [[DBG27:![0-9]+]]
79 ; DBGINFO-NEXT: br label [[END]], !dbg [[DBG28:![0-9]+]]
82 call void @sideeffect0()
83 br i1 %C0, label %T, label %F
86 ; empty block with single predecessor
90 %r = phi i32 [ %v0, %T.cont ], [ %v1, %T ], [ %v2, %F ]
95 call void @sideeffect1()
96 br i1 %C1, label %T.cont, label %end
99 call void @sideeffect2()