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 ; A PHINode defines the global value number of a split phi node for
5 ; an exit paths based on the canonical number for the incoming values, and
6 ; the canonical number for the basic block. This checks that we accurately
7 ; capture a different numbering for the same incoming value but with different
10 define void @func1(i32 %0, i32 %1) local_unnamed_addr #0 {
17 %c = icmp eq i32 %b, 1
18 br i1 %c, label %bb5, label %bb3
29 %f = phi i32 [ 0, %bb1 ], [ 1, %bb2 ], [ 1, %bb3 ]
33 define void @func2(i32 %0, i32 %1) local_unnamed_addr #0 {
40 %c = icmp eq i32 %b, 1
41 br i1 %c, label %bb5, label %bb3
52 %f = phi i32 [ 0, %bb1 ], [ 1, %bb3 ], [ 1, %bb2 ]
55 ; CHECK-LABEL: @func1(
57 ; CHECK-NEXT: [[F_CE_LOC:%.*]] = alloca i32, align 4
58 ; CHECK-NEXT: br label [[BB5:%.*]]
60 ; CHECK-NEXT: [[A:%.*]] = add i32 [[TMP0:%.*]], [[TMP1:%.*]]
61 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[F_CE_LOC]])
62 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[TMP0]], i32 [[TMP1]], ptr [[F_CE_LOC]], i32 0)
63 ; CHECK-NEXT: [[F_CE_RELOAD:%.*]] = load i32, ptr [[F_CE_LOC]], align 4
64 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[F_CE_LOC]])
65 ; CHECK-NEXT: br label [[BB5]]
67 ; CHECK-NEXT: [[E:%.*]] = sub i32 [[TMP0]], [[TMP1]]
68 ; CHECK-NEXT: br label [[BB2:%.*]]
70 ; CHECK-NEXT: [[F:%.*]] = phi i32 [ 0, [[BB1:%.*]] ], [ [[F_CE_RELOAD]], [[BB2]] ]
71 ; CHECK-NEXT: ret void
74 ; CHECK-LABEL: @func2(
76 ; CHECK-NEXT: [[F_CE_LOC:%.*]] = alloca i32, align 4
77 ; CHECK-NEXT: br label [[BB5:%.*]]
79 ; CHECK-NEXT: [[A:%.*]] = sub i32 [[TMP0:%.*]], [[TMP1:%.*]]
80 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[F_CE_LOC]])
81 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[TMP0]], i32 [[TMP1]], ptr [[F_CE_LOC]], i32 1)
82 ; CHECK-NEXT: [[F_CE_RELOAD:%.*]] = load i32, ptr [[F_CE_LOC]], align 4
83 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[F_CE_LOC]])
84 ; CHECK-NEXT: br label [[BB5]]
86 ; CHECK-NEXT: [[E:%.*]] = add i32 [[TMP0]], [[TMP1]]
87 ; CHECK-NEXT: br label [[BB2:%.*]]
89 ; CHECK-NEXT: [[F:%.*]] = phi i32 [ 0, [[BB1:%.*]] ], [ [[F_CE_RELOAD]], [[BB2]] ]
90 ; CHECK-NEXT: ret void
93 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
94 ; CHECK-NEXT: newFuncRoot:
95 ; CHECK-NEXT: br label [[BB2_TO_OUTLINE:%.*]]
96 ; CHECK: bb2_to_outline:
97 ; CHECK-NEXT: [[B:%.*]] = add i32 [[TMP0:%.*]], [[TMP1:%.*]]
98 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B]], 1
99 ; CHECK-NEXT: br i1 [[C]], label [[BB5_SPLIT:%.*]], label [[BB3:%.*]]
101 ; CHECK-NEXT: [[D:%.*]] = add i32 [[TMP0]], [[TMP1]]
102 ; CHECK-NEXT: br label [[BB5_SPLIT]]
104 ; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ 1, [[BB3]] ], [ 1, [[BB2_TO_OUTLINE]] ]
105 ; CHECK-NEXT: [[F_CE:%.*]] = phi i32 [ 1, [[BB2_TO_OUTLINE]] ], [ 1, [[BB3]] ]
106 ; CHECK-NEXT: br label [[BB5_EXITSTUB:%.*]]
107 ; CHECK: bb5.exitStub:
108 ; CHECK-NEXT: switch i32 [[TMP3:%.*]], label [[FINAL_BLOCK_0:%.*]] [
109 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_0_0:%.*]]
110 ; CHECK-NEXT: i32 1, label [[OUTPUT_BLOCK_1_0:%.*]]
112 ; CHECK: output_block_0_0:
113 ; CHECK-NEXT: store i32 [[F_CE]], ptr [[TMP2:%.*]], align 4
114 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
115 ; CHECK: output_block_1_0:
116 ; CHECK-NEXT: store i32 [[TMP4]], ptr [[TMP2]], align 4
117 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
118 ; CHECK: final_block_0:
119 ; CHECK-NEXT: ret void