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 differentiate between outputs of the region stored in PHINodes
5 ; versus those stored outside of PHINodes.
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 %test
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 %test
34 %d = load i32, ptr %0, align 4
35 br i1 true, label %first, label %next
43 ; CHECK-LABEL: @function1(
45 ; CHECK-NEXT: [[DOTCE_LOC:%.*]] = alloca i32, align 4
46 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
47 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTCE_LOC]])
48 ; CHECK-NEXT: [[TMP1:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]], ptr null, i32 0)
49 ; CHECK-NEXT: [[DOTCE_RELOAD:%.*]] = load i32, ptr [[DOTCE_LOC]], align 4
50 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTCE_LOC]])
51 ; CHECK-NEXT: br i1 [[TMP1]], label [[FIRST:%.*]], label [[NEXT:%.*]]
53 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
54 ; CHECK-NEXT: ret void
56 ; CHECK-NEXT: ret void
59 ; CHECK-LABEL: @function2(
61 ; CHECK-NEXT: [[E_LOC:%.*]] = alloca i32, align 4
62 ; CHECK-NEXT: [[C_LOC:%.*]] = alloca i32, align 4
63 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
64 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[C_LOC]])
65 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[E_LOC]])
66 ; CHECK-NEXT: [[TMP1:%.*]] = call i1 @outlined_ir_func_0(ptr [[TMP0]], ptr [[C_LOC]], ptr [[E_LOC]], i32 1)
67 ; CHECK-NEXT: [[C_RELOAD:%.*]] = load i32, ptr [[C_LOC]], align 4
68 ; CHECK-NEXT: [[E_RELOAD:%.*]] = load i32, ptr [[E_LOC]], align 4
69 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[C_LOC]])
70 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[E_LOC]])
71 ; CHECK-NEXT: br i1 [[TMP1]], label [[FIRST:%.*]], label [[NEXT:%.*]]
73 ; CHECK-NEXT: ret void
75 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[C_RELOAD]], 1
76 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[E_RELOAD]], 1
77 ; CHECK-NEXT: ret void
80 ; CHECK-LABEL: define internal i1 @outlined_ir_func_0(
81 ; CHECK-NEXT: newFuncRoot:
82 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
83 ; CHECK: entry_to_outline:
84 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
85 ; CHECK-NEXT: br label [[TEST1:%.*]]
87 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[TMP0]], align 4
88 ; CHECK-NEXT: br i1 true, label [[FIRST_SPLIT:%.*]], label [[TEST:%.*]]
90 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP0]], align 4
91 ; CHECK-NEXT: br i1 true, label [[FIRST_SPLIT]], label [[NEXT_EXITSTUB:%.*]]
93 ; CHECK-NEXT: [[DOTCE:%.*]] = phi i32 [ [[C]], [[TEST]] ], [ [[E]], [[TEST1]] ]
94 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
95 ; CHECK: first.exitStub:
96 ; CHECK-NEXT: switch i32 [[TMP3:%.*]], label [[FINAL_BLOCK_1:%.*]] [
97 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_0_1:%.*]]
98 ; CHECK-NEXT: i32 1, label [[OUTPUT_BLOCK_1_1:%.*]]
100 ; CHECK: next.exitStub:
101 ; CHECK-NEXT: switch i32 [[TMP3]], label [[FINAL_BLOCK_0:%.*]] [
102 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_1_0:%.*]]
104 ; CHECK: output_block_0_1:
105 ; CHECK-NEXT: store i32 [[DOTCE]], ptr [[TMP1:%.*]], align 4
106 ; CHECK-NEXT: br label [[FINAL_BLOCK_1]]
107 ; CHECK: output_block_1_0:
108 ; CHECK-NEXT: store i32 [[C]], ptr [[TMP1]], align 4
109 ; CHECK-NEXT: store i32 [[E]], ptr [[TMP2:%.*]], align 4
110 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
111 ; CHECK: output_block_1_1:
112 ; CHECK-NEXT: store i32 [[C]], ptr [[TMP1]], align 4
113 ; CHECK-NEXT: store i32 [[E]], ptr [[TMP2]], align 4
114 ; CHECK-NEXT: br label [[FINAL_BLOCK_1]]
115 ; CHECK: final_block_0:
116 ; CHECK-NEXT: ret i1 false
117 ; CHECK: final_block_1:
118 ; CHECK-NEXT: ret i1 true