1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=iroutliner -ir-outlining-no-cost < %s | FileCheck %s
4 ; This test tests that inputs that are replaced with the output of an outlined
5 ; function is still recognized as the same value.
7 define void @outline_outputs1() #0 {
8 ; CHECK-LABEL: @outline_outputs1(
10 ; CHECK-NEXT: [[DOTLOC2:%.*]] = alloca i32, align 4
11 ; CHECK-NEXT: [[ADD2_LOC:%.*]] = alloca i32, align 4
12 ; CHECK-NEXT: [[DOTLOC:%.*]] = alloca i32, align 4
13 ; CHECK-NEXT: [[ADD_LOC:%.*]] = alloca i32, align 4
14 ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
15 ; CHECK-NEXT: [[B:%.*]] = alloca i32, align 4
16 ; CHECK-NEXT: [[OUTPUT:%.*]] = alloca i32, align 4
17 ; CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
18 ; CHECK-NEXT: [[OUTPUT2:%.*]] = alloca i32, align 4
19 ; CHECK-NEXT: [[RESULT2:%.*]] = alloca i32, align 4
20 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[ADD_LOC]])
21 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTLOC]])
22 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 2, ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[ADD_LOC]], ptr [[DOTLOC]])
23 ; CHECK-NEXT: [[ADD_RELOAD:%.*]] = load i32, ptr [[ADD_LOC]], align 4
24 ; CHECK-NEXT: [[DOTRELOAD:%.*]] = load i32, ptr [[DOTLOC]], align 4
25 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[ADD_LOC]])
26 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTLOC]])
27 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[OUTPUT]], align 4
28 ; CHECK-NEXT: call void @outlined_ir_func_1(i32 [[DOTRELOAD]], i32 [[ADD_RELOAD]], ptr [[RESULT]])
29 ; CHECK-NEXT: br label [[NEXT:%.*]]
31 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[ADD2_LOC]])
32 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[DOTLOC2]])
33 ; CHECK-NEXT: call void @outlined_ir_func_0(i32 [[ADD_RELOAD]], ptr [[OUTPUT]], ptr [[RESULT]], ptr [[OUTPUT2]], ptr [[ADD2_LOC]], ptr [[DOTLOC2]])
34 ; CHECK-NEXT: [[ADD2_RELOAD:%.*]] = load i32, ptr [[ADD2_LOC]], align 4
35 ; CHECK-NEXT: [[DOTRELOAD3:%.*]] = load i32, ptr [[DOTLOC2]], align 4
36 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[ADD2_LOC]])
37 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 -1, ptr [[DOTLOC2]])
38 ; CHECK-NEXT: call void @outlined_ir_func_1(i32 [[DOTRELOAD3]], i32 [[ADD2_RELOAD]], ptr [[RESULT2]])
39 ; CHECK-NEXT: ret void
42 %a = alloca i32, align 4
43 %b = alloca i32, align 4
44 %output = alloca i32, align 4
45 %result = alloca i32, align 4
46 %output2 = alloca i32, align 4
47 %result2 = alloca i32, align 4
48 store i32 2, ptr %a, align 4
49 store i32 3, ptr %b, align 4
50 %0 = load i32, ptr %a, align 4
51 %1 = load i32, ptr %b, align 4
53 store i32 %add, ptr %output, align 4
54 %2 = load i32, ptr %output, align 4
55 %3 = load i32, ptr %output, align 4
56 %mul = mul i32 %2, %add
57 store i32 %mul, ptr %result, align 4
60 store i32 %add, ptr %output, align 4
61 store i32 3, ptr %result, align 4
62 %4 = load i32, ptr %output, align 4
63 %5 = load i32, ptr %result, align 4
64 %add2 = add i32 %4, %5
65 store i32 %add2, ptr %output2, align 4
66 %6 = load i32, ptr %output2, align 4
67 %mul2 = mul i32 %6, %add2
68 store i32 %mul2, ptr %result2, align 4