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 are able to extract blocks that contain PHINodes, and selectively
5 ; store into it's respective block, creating a new block if needed.
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
22 define void @function2(ptr %a, ptr %b) {
24 %0 = alloca i32, align 4
25 %c = load i32, ptr %0, align 4
28 %e = load i32, ptr %0, align 4
31 %d = load i32, ptr %0, align 4
34 %1 = phi i32 [ %c, %test ], [ %e, %test1 ]
37 ; CHECK-LABEL: @function1(
39 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
40 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], ptr null, i32 -1)
41 ; CHECK-NEXT: br label [[FIRST:%.*]]
43 ; CHECK-NEXT: ret void
46 ; CHECK-LABEL: @function2(
48 ; CHECK-NEXT: [[DOTCE_LOC:%.*]] = alloca i32, align 4
49 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
50 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTCE_LOC]])
51 ; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[TMP0]], ptr [[DOTCE_LOC]], i32 0)
52 ; CHECK-NEXT: [[DOTCE_RELOAD:%.*]] = load i32, ptr [[DOTCE_LOC]], align 4
53 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTCE_LOC]])
54 ; CHECK-NEXT: br label [[FIRST:%.*]]
56 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
57 ; CHECK-NEXT: ret void
60 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
61 ; CHECK-NEXT: newFuncRoot:
62 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
63 ; CHECK: entry_to_outline:
64 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
65 ; CHECK-NEXT: br label [[TEST1:%.*]]
67 ; CHECK-NEXT: [[E:%.*]] = load i32, ptr [[TMP0]], align 4
68 ; CHECK-NEXT: br label [[PHI_BLOCK:%.*]]
70 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP0]], align 4
71 ; CHECK-NEXT: br label [[PHI_BLOCK]]
72 ; CHECK: first.exitStub:
73 ; CHECK-NEXT: switch i32 [[TMP2:%.*]], label [[FINAL_BLOCK_0:%.*]] [
74 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_1_0:%.*]]
76 ; CHECK: output_block_1_0:
77 ; CHECK-NEXT: store i32 [[TMP3:%.*]], ptr [[TMP1:%.*]], align 4
78 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
80 ; CHECK-NEXT: [[TMP3]] = phi i32 [ [[C]], [[TEST:%.*]] ], [ [[E]], [[TEST1]] ]
81 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
82 ; CHECK: final_block_0:
83 ; CHECK-NEXT: ret void