1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; Show that we do not outline when all of the phi nodes in the beginning
5 ; block are included not in the region.
7 define void @function1(ptr %a, ptr %b) {
9 %0 = alloca i32, align 4
10 %c = load i32, ptr %0, align 4
16 %1 = phi i32 [ %e, %test1 ], [ %y, %entry ]
17 %2 = phi i32 [ %e, %test1 ], [ %y, %entry ]
18 %e = load i32, ptr %0, align 4
20 br i1 true, label %test, label %test1
22 %d = load i32, ptr %0, align 4
28 define void @function2(ptr %a, ptr %b) {
30 %0 = alloca i32, align 4
31 %c = load i32, ptr %0, align 4
37 %1 = phi i32 [ %e, %test1 ], [ %y, %entry ]
38 %2 = phi i32 [ %y, %entry ], [ %e, %test1 ]
39 %e = load i32, ptr %0, align 4
41 br i1 true, label %test, label %test1
43 %d = load i32, ptr %0, align 4
48 ; CHECK-LABEL: @function1(
50 ; CHECK-NEXT: [[E_LOC:%.*]] = alloca i32, align 4
51 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
52 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
53 ; CHECK-NEXT: [[Y:%.*]] = add i32 [[C]], [[C]]
54 ; CHECK-NEXT: br label [[TEST1:%.*]]
56 ; CHECK-NEXT: ret void
58 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[E_RELOAD:%.*]], [[TEST1]] ], [ [[Y]], [[ENTRY:%.*]] ]
59 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[E_RELOAD]], [[TEST1]] ], [ [[Y]], [[ENTRY]] ]
60 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[E_LOC]])
61 ; CHECK-NEXT: [[TARGETBLOCK:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], i32 [[C]], ptr [[E_LOC]])
62 ; CHECK-NEXT: [[E_RELOAD]] = load i32, ptr [[E_LOC]], align 4
63 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[E_LOC]])
64 ; CHECK-NEXT: br i1 [[TARGETBLOCK]], label [[TEST1]], label [[FIRST:%.*]]
66 ; CHECK-NEXT: ret void
69 ; CHECK-LABEL: @function2(
71 ; CHECK-NEXT: [[E_LOC:%.*]] = alloca i32, align 4
72 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
73 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
74 ; CHECK-NEXT: [[Y:%.*]] = mul i32 [[C]], [[C]]
75 ; CHECK-NEXT: br label [[TEST1:%.*]]
77 ; CHECK-NEXT: ret void
79 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[E_RELOAD:%.*]], [[TEST1]] ], [ [[Y]], [[ENTRY:%.*]] ]
80 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[Y]], [[ENTRY]] ], [ [[E_RELOAD]], [[TEST1]] ]
81 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[E_LOC]])
82 ; CHECK-NEXT: [[TARGETBLOCK:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], i32 [[C]], ptr [[E_LOC]])
83 ; CHECK-NEXT: [[E_RELOAD]] = load i32, ptr [[E_LOC]], align 4
84 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[E_LOC]])
85 ; CHECK-NEXT: br i1 [[TARGETBLOCK]], label [[TEST1]], label [[FIRST:%.*]]
87 ; CHECK-NEXT: ret void
90 ; CHECK: define internal i1 @outlined_ir_func_0(
91 ; CHECK-NEXT: newFuncRoot:
92 ; CHECK-NEXT: br label [[TEST1_TO_OUTLINE:%.*]]
93 ; CHECK: test1_to_outline:
94 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
95 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP1:%.*]], [[TMP1]]
96 ; CHECK-NEXT: br i1 true, label [[TEST:%.*]], label [[TEST1_EXITSTUB:%.*]]
98 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP0]], align 4
99 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
100 ; CHECK: test1.exitStub:
101 ; CHECK-NEXT: store i32 [[E]], ptr [[TMP2:%.*]], align 4
102 ; CHECK-NEXT: ret i1 true
103 ; CHECK: first.exitStub:
104 ; CHECK-NEXT: store i32 [[E]], ptr [[TMP2]], align 4
105 ; CHECK-NEXT: ret i1 false