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
21 br i1 true, label %first, label %test1
26 define void @function2(ptr %a, ptr %b) {
28 %0 = alloca i32, align 4
29 %c = load i32, ptr %0, align 4
35 %1 = phi i32 [ %e, %test1 ], [ %y, %entry ]
36 %2 = phi i32 [ %y, %entry ], [ %e, %test1 ]
37 %e = load i32, ptr %0, align 4
40 br i1 true, label %first, label %test1
44 ; CHECK-LABEL: @function1(
46 ; CHECK-NEXT: [[E_LOC:%.*]] = alloca i32, align 4
47 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
48 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
49 ; CHECK-NEXT: [[Y:%.*]] = add i32 [[C]], [[C]]
50 ; CHECK-NEXT: br label [[TEST1:%.*]]
52 ; CHECK-NEXT: ret void
54 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[E_RELOAD:%.*]], [[TEST1]] ], [ [[Y]], [[ENTRY:%.*]] ]
55 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[E_RELOAD]], [[TEST1]] ], [ [[Y]], [[ENTRY]] ]
56 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[E_LOC]])
57 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], i32 [[C]], ptr [[E_LOC]])
58 ; CHECK-NEXT: [[E_RELOAD]] = load i32, ptr [[E_LOC]], align 4
59 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[E_LOC]])
60 ; CHECK-NEXT: [[TMP3:%.*]] = sub i32 [[C]], [[C]]
61 ; CHECK-NEXT: br i1 true, label [[FIRST:%.*]], label [[TEST1]]
63 ; CHECK-NEXT: ret void
66 ; CHECK-LABEL: @function2(
68 ; CHECK-NEXT: [[E_LOC:%.*]] = alloca i32, align 4
69 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
70 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
71 ; CHECK-NEXT: [[Y:%.*]] = mul i32 [[C]], [[C]]
72 ; CHECK-NEXT: br label [[TEST1:%.*]]
74 ; CHECK-NEXT: ret void
76 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[E_RELOAD:%.*]], [[TEST1]] ], [ [[Y]], [[ENTRY:%.*]] ]
77 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[Y]], [[ENTRY]] ], [ [[E_RELOAD]], [[TEST1]] ]
78 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[E_LOC]])
79 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], i32 [[C]], ptr [[E_LOC]])
80 ; CHECK-NEXT: [[E_RELOAD]] = load i32, ptr [[E_LOC]], align 4
81 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[E_LOC]])
82 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[C]], [[C]]
83 ; CHECK-NEXT: br i1 true, label [[FIRST:%.*]], label [[TEST1]]
85 ; CHECK-NEXT: ret void
88 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
89 ; CHECK-NEXT: newFuncRoot:
90 ; CHECK-NEXT: br label [[TEST1_TO_OUTLINE:%.*]]
91 ; CHECK: test1_to_outline:
92 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
93 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP1:%.*]], [[TMP1]]
94 ; CHECK-NEXT: br label [[TEST1_AFTER_OUTLINE_EXITSTUB:%.*]]
95 ; CHECK: test1_after_outline.exitStub:
96 ; CHECK-NEXT: store i32 [[E]], ptr [[TMP2:%.*]], align 4
97 ; CHECK-NEXT: ret void