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
14 br i1 true, label %first, label %next
16 %d = load i32, ptr %0, align 4
17 br i1 true, label %first, label %next
19 %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
32 br i1 true, label %first, label %next
34 %d = load i32, ptr %0, align 4
35 br i1 true, label %first, label %next
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: [[TMP1:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]], i32 0)
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 i1 [[TMP1]], label [[FIRST:%.*]], label [[NEXT:%.*]]
52 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
53 ; CHECK-NEXT: ret void
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: [[TMP1:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]], i32 1)
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 i1 [[TMP1]], label [[FIRST:%.*]], label [[NEXT:%.*]]
68 ; CHECK-NEXT: ret void
70 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
71 ; CHECK-NEXT: ret void
74 ; CHECK-LABEL: define internal i1 @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 i1 true, label [[FIRST_SPLIT:%.*]], label [[PHI_BLOCK:%.*]]
84 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP0]], align 4
85 ; CHECK-NEXT: br i1 true, label [[FIRST_SPLIT]], label [[PHI_BLOCK]]
87 ; CHECK-NEXT: [[DOTCE:%.*]] = phi i32 [ [[C]], [[TEST:%.*]] ], [ [[E]], [[TEST1]] ]
88 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
89 ; CHECK: first.exitStub:
90 ; CHECK-NEXT: switch i32 [[TMP2:%.*]], label [[FINAL_BLOCK_1:%.*]] [
91 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_0_1:%.*]]
93 ; CHECK: next.exitStub:
94 ; CHECK-NEXT: switch i32 [[TMP2]], label [[FINAL_BLOCK_0:%.*]] [
95 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_1_0:%.*]]
97 ; CHECK: output_block_0_1:
98 ; CHECK-NEXT: store i32 [[DOTCE]], ptr [[TMP1:%.*]], align 4
99 ; CHECK-NEXT: br label [[FINAL_BLOCK_1]]
100 ; CHECK: output_block_1_0:
101 ; CHECK-NEXT: store i32 [[TMP3:%.*]], ptr [[TMP1]], align 4
102 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
104 ; CHECK-NEXT: [[TMP3]] = phi i32 [ [[C]], [[TEST]] ], [ [[E]], [[TEST1]] ]
105 ; CHECK-NEXT: br label [[NEXT_EXITSTUB:%.*]]
106 ; CHECK: final_block_0:
107 ; CHECK-NEXT: ret i1 false
108 ; CHECK: final_block_1:
109 ; CHECK-NEXT: ret i1 true