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 extract similar regions that would involve the splitting
5 ; of phi nodes on exit.
7 define void @function1(ptr %a, ptr %b) {
9 %0 = alloca i32, align 4
10 %c = load i32, ptr %0, align 4
13 %e = load i32, ptr %0, align 4
16 %d = load i32, ptr %0, align 4
21 %1 = phi i32 [ %c, %test ], [ %e, %test1 ]
25 define void @function2(ptr %a, ptr %b) {
27 %0 = alloca i32, align 4
28 %c = load i32, ptr %0, align 4
31 %e = load i32, ptr %0, align 4
34 %d = load i32, ptr %0, align 4
39 %1 = phi i32 [ %c, %test ], [ %e, %test1 ]
42 ; CHECK-LABEL: @function1(
44 ; CHECK-NEXT: [[DOTCE_LOC:%.*]] = alloca i32, align 4
45 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
46 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTCE_LOC]])
47 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]])
48 ; CHECK-NEXT: [[DOTCE_RELOAD:%.*]] = load i32, ptr [[DOTCE_LOC]], align 4
49 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTCE_LOC]])
50 ; CHECK-NEXT: br label [[FIRST:%.*]]
52 ; CHECK-NEXT: ret void
54 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
55 ; CHECK-NEXT: ret void
58 ; CHECK-LABEL: @function2(
60 ; CHECK-NEXT: [[DOTCE_LOC:%.*]] = alloca i32, align 4
61 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
62 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTCE_LOC]])
63 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]])
64 ; CHECK-NEXT: [[DOTCE_RELOAD:%.*]] = load i32, ptr [[DOTCE_LOC]], align 4
65 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTCE_LOC]])
66 ; CHECK-NEXT: br label [[FIRST:%.*]]
68 ; CHECK-NEXT: ret void
70 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
71 ; CHECK-NEXT: ret void
74 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
75 ; CHECK-NEXT: newFuncRoot:
76 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
77 ; CHECK: entry_to_outline:
78 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
79 ; CHECK-NEXT: br label [[TEST1:%.*]]
81 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[TMP0]], align 4
82 ; CHECK-NEXT: br label [[FIRST_SPLIT:%.*]]
84 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP0]], align 4
85 ; CHECK-NEXT: br label [[FIRST_SPLIT]]
87 ; CHECK-NEXT: [[DOTCE:%.*]] = phi i32 [ [[C]], [[TEST:%.*]] ], [ [[E]], [[TEST1]] ]
88 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
89 ; CHECK: first.exitStub:
90 ; CHECK-NEXT: store i32 [[DOTCE]], ptr [[TMP1:%.*]], align 4
91 ; CHECK-NEXT: ret void