1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs
2 ; RUN: opt -S -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(i32* %a, i32* %b) {
9 %0 = alloca i32, align 4
10 %c = load i32, i32* %0, align 4
13 %e = load i32, i32* %0, align 4
16 %d = load i32, i32* %0, align 4
22 define void @function2(i32* %a, i32* %b) {
24 %0 = alloca i32, align 4
25 %c = load i32, i32* %0, align 4
28 %e = load i32, i32* %0, align 4
31 %d = load i32, i32* %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(i32* [[TMP0]], i32* 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: [[LT_CAST:%.*]] = bitcast i32* [[DOTCE_LOC]] to i8*
51 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 -1, i8* [[LT_CAST]])
52 ; CHECK-NEXT: call void @outlined_ir_func_0(i32* [[TMP0]], i32* [[DOTCE_LOC]], i32 0)
53 ; CHECK-NEXT: [[DOTCE_RELOAD:%.*]] = load i32, i32* [[DOTCE_LOC]], align 4
54 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 -1, i8* [[LT_CAST]])
55 ; CHECK-NEXT: br label [[FIRST:%.*]]
57 ; CHECK-NEXT: [[TMP1:%.*]] = phi i32 [ [[DOTCE_RELOAD]], [[ENTRY:%.*]] ]
58 ; CHECK-NEXT: ret void
61 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
62 ; CHECK-NEXT: newFuncRoot:
63 ; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]]
64 ; CHECK: entry_to_outline:
65 ; CHECK-NEXT: [[C:%.*]] = load i32, i32* [[TMP0:%.*]], align 4
66 ; CHECK-NEXT: br label [[TEST1:%.*]]
68 ; CHECK-NEXT: [[E:%.*]] = load i32, i32* [[TMP0]], align 4
69 ; CHECK-NEXT: br label [[PHI_BLOCK:%.*]]
71 ; CHECK-NEXT: [[D:%.*]] = load i32, i32* [[TMP0]], align 4
72 ; CHECK-NEXT: br label [[PHI_BLOCK]]
73 ; CHECK: first.exitStub:
74 ; CHECK-NEXT: switch i32 [[TMP2:%.*]], label [[FINAL_BLOCK_0:%.*]] [
75 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_1_0:%.*]]
77 ; CHECK: output_block_1_0:
78 ; CHECK-NEXT: store i32 [[TMP3:%.*]], i32* [[TMP1:%.*]], align 4
79 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
81 ; CHECK-NEXT: [[TMP3]] = phi i32 [ [[C]], [[TEST:%.*]] ], [ [[E]], [[TEST1]] ]
82 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
83 ; CHECK: final_block_0:
84 ; CHECK-NEXT: ret void