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 ; When consolidating PHINodes, the outliner replaces the incoming value with
5 ; a corresponding value from the first outlined section. When this replaced
6 ; value is passed in as an argument, the corresponding value is found outside
7 ; of the outlined region, and must be replaced with an argument to avoid
8 ; dominating value errors. This checks that we use the argument to replace
11 define void @func1(i32 %0, i32 %1) local_unnamed_addr #0 {
18 %c = icmp eq i32 %b, %a
19 br i1 %c, label %bb5, label %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, %bb2 ], [ 1, %bb3 ]
55 ; CHECK-LABEL: @func1(
57 ; CHECK-NEXT: br label [[BB5:%.*]]
59 ; CHECK-NEXT: [[A:%.*]] = add i32 [[TMP0:%.*]], [[TMP1:%.*]]
60 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[TMP0]], i32 [[TMP1]], i32 [[A]], ptr null, i32 -1)
61 ; CHECK-NEXT: br label [[BB5]]
63 ; CHECK-NEXT: [[E:%.*]] = sub i32 [[TMP0]], [[TMP1]]
64 ; CHECK-NEXT: br label [[BB2:%.*]]
66 ; CHECK-NEXT: ret void
69 ; CHECK-LABEL: @func2(
71 ; CHECK-NEXT: [[F_CE_LOC:%.*]] = alloca i32, align 4
72 ; CHECK-NEXT: br label [[BB5:%.*]]
74 ; CHECK-NEXT: [[A:%.*]] = sub i32 [[TMP0:%.*]], [[TMP1:%.*]]
75 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[F_CE_LOC]])
76 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[TMP0]], i32 [[TMP1]], i32 1, ptr [[F_CE_LOC]], i32 0)
77 ; CHECK-NEXT: [[F_CE_RELOAD:%.*]] = load i32, ptr [[F_CE_LOC]], align 4
78 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[F_CE_LOC]])
79 ; CHECK-NEXT: br label [[BB5]]
81 ; CHECK-NEXT: [[E:%.*]] = add i32 [[TMP0]], [[TMP1]]
82 ; CHECK-NEXT: br label [[BB2:%.*]]
84 ; CHECK-NEXT: [[F:%.*]] = phi i32 [ 0, [[BB1:%.*]] ], [ [[F_CE_RELOAD]], [[BB2]] ]
85 ; CHECK-NEXT: ret void
88 ; CHECK-LABEL: define internal void @outlined_ir_func_0(
89 ; CHECK-NEXT: newFuncRoot:
90 ; CHECK-NEXT: br label [[BB2_TO_OUTLINE:%.*]]
91 ; CHECK: bb2_to_outline:
92 ; CHECK-NEXT: [[B:%.*]] = add i32 [[TMP0:%.*]], [[TMP1:%.*]]
93 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[B]], [[TMP2:%.*]]
94 ; CHECK-NEXT: br i1 [[C]], label [[PHI_BLOCK:%.*]], label [[BB3:%.*]]
96 ; CHECK-NEXT: [[D:%.*]] = add i32 [[TMP0]], [[TMP1]]
97 ; CHECK-NEXT: br label [[PHI_BLOCK]]
98 ; CHECK: bb5.exitStub:
99 ; CHECK-NEXT: switch i32 [[TMP4:%.*]], label [[FINAL_BLOCK_0:%.*]] [
100 ; CHECK-NEXT: i32 0, label [[OUTPUT_BLOCK_1_0:%.*]]
102 ; CHECK: output_block_1_0:
103 ; CHECK-NEXT: store i32 [[TMP5:%.*]], ptr [[TMP3:%.*]], align 4
104 ; CHECK-NEXT: br label [[FINAL_BLOCK_0]]
106 ; CHECK-NEXT: [[TMP5]] = phi i32 [ [[TMP2]], [[BB2_TO_OUTLINE]] ], [ [[TMP2]], [[BB3]] ]
107 ; CHECK-NEXT: br label [[BB5_EXITSTUB:%.*]]
108 ; CHECK: final_block_0:
109 ; CHECK-NEXT: ret void