xref: /llvm-project/llvm/test/Transforms/CodeExtractor/PartialInlineEntryPHICost.ll (revision 9d68270faec1804a88b30e4b1420681a409d6892)
1; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
2
3; Check that we do not overcompute the outlined region cost, where the PHIs in
4; the outlined region entry (BB4) are moved outside the region by CodeExtractor.
5
6define i32 @bar(i32 %arg) {
7bb:
8  %tmp = icmp slt i32 %arg, 0
9  br i1 %tmp, label %bb1, label %bb2
10
11bb1:
12  br i1 %tmp, label %bb4, label %bb2
13
14bb2:                                              ; preds = %bb, %bb1
15  br i1 %tmp, label %bb4, label %bb5
16
17bb4:                                              ; preds = %bb1, %bb2
18  %xx1 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
19  %xx2 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
20  %xx3 = phi i32 [ 1, %bb1 ], [ 9, %bb2 ]
21  tail call void (...) @foo() #2
22  br label %bb5
23
24bb5:                                              ; preds = %bb4, %bb2
25  %tmp6 = phi i32 [ 1, %bb2 ], [ 9, %bb4 ]
26  ret i32 %tmp6
27}
28
29declare void @foo(...)
30
31define i32 @dummy_caller(i32 %arg) {
32bb:
33; CHECK-LABEL: @dummy_caller
34; CHECK: br i1
35; CHECK: br i1
36; CHECK: call void @bar.1.
37  %tmp = tail call i32 @bar(i32 %arg)
38  ret i32 %tmp
39}
40