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 outline when all of the phi nodes in the starting
5 ; block are included in the region and there is no more than one predecessor
6 ; into those phi nodes from outside of the region.
8 define void @function1(ptr %a, ptr %b) {
10 %0 = alloca i32, align 4
11 %c = load i32, ptr %0, align 4
17 %1 = phi i32 [ %e, %test1 ], [ %y, %entry ]
18 %2 = phi i32 [ %e, %test1 ], [ %y, %entry ]
19 %e = load i32, ptr %0, align 4
21 br i1 true, label %test, label %test1
23 %d = load i32, ptr %0, align 4
29 define void @function2(ptr %a, ptr %b) {
31 %0 = alloca i32, align 4
32 %c = load i32, ptr %0, align 4
38 %1 = phi i32 [ %e, %test1 ], [ %y, %entry ]
39 %2 = phi i32 [ %e, %test1 ], [ %y, %entry ]
40 %e = load i32, ptr %0, align 4
42 br i1 true, label %test, label %test1
44 %d = load i32, ptr %0, align 4
49 ; CHECK-LABEL: @function1(
51 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
52 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
53 ; CHECK-NEXT: [[Y:%.*]] = add i32 [[C]], [[C]]
54 ; CHECK-NEXT: br label [[TEST1:%.*]]
56 ; CHECK-NEXT: ret void
58 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[Y]], ptr [[TMP0]], i32 [[C]])
59 ; CHECK-NEXT: br label [[FIRST:%.*]]
61 ; CHECK-NEXT: ret void
64 ; CHECK-LABEL: @function2(
66 ; CHECK-NEXT: [[TMP0:%.*]] = alloca i32, align 4
67 ; CHECK-NEXT: [[C:%.*]] = load i32, ptr [[TMP0]], align 4
68 ; CHECK-NEXT: [[Y:%.*]] = mul i32 [[C]], [[C]]
69 ; CHECK-NEXT: br label [[TEST1:%.*]]
71 ; CHECK-NEXT: ret void
73 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[Y]], ptr [[TMP0]], i32 [[C]])
74 ; CHECK-NEXT: br label [[FIRST:%.*]]
76 ; CHECK-NEXT: ret void
79 ; CHECK: define internal void @outlined_ir_func_0(
80 ; CHECK-NEXT: newFuncRoot:
81 ; CHECK-NEXT: br label [[TEST1_TO_OUTLINE:%.*]]
82 ; CHECK: test1_to_outline:
83 ; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ [[E:%.*]], [[TEST1_TO_OUTLINE]] ], [ [[TMP0:%.*]], [[NEWFUNCROOT:%.*]] ]
84 ; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ [[E]], [[TEST1_TO_OUTLINE]] ], [ [[TMP0]], [[NEWFUNCROOT]] ]
85 ; CHECK-NEXT: [[E]] = load i32, ptr [[TMP1:%.*]], align 4
86 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[TMP2:%.*]], [[TMP2]]
87 ; CHECK-NEXT: br i1 true, label [[TEST:%.*]], label [[TEST1_TO_OUTLINE]]
89 ; CHECK-NEXT: [[D:%.*]] = load i32, ptr [[TMP1]], align 4
90 ; CHECK-NEXT: br label [[FIRST_EXITSTUB:%.*]]
91 ; CHECK: first.exitStub:
92 ; CHECK-NEXT: ret void