xref: /llvm-project/llvm/test/Transforms/IROutliner/outlining-across-branch.ll (revision f4b925ee7078f058602fd323e25f45f1ae91ca34)
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
3
4; This checks that we are able to outline exactly the same branch structure
5; while also outlining similar items on either side of the branch.
6
7define void @outline_outputs1() #0 {
8entry:
9  %a = alloca i32, align 4
10  %b = alloca i32, align 4
11  %output = alloca i32, align 4
12  %result = alloca i32, align 4
13  %output2 = alloca i32, align 4
14  %result2 = alloca i32, align 4
15  store i32 2, ptr %a, align 4
16  store i32 3, ptr %b, align 4
17  br label %next
18next:
19  store i32 2, ptr %output, align 4
20  store i32 3, ptr %result, align 4
21  ret void
22}
23
24define void @outline_outputs2() #0 {
25entry:
26  %a = alloca i32, align 4
27  %b = alloca i32, align 4
28  %output = alloca i32, align 4
29  %result = alloca i32, align 4
30  %output2 = alloca i32, align 4
31  %result2 = alloca i32, align 4
32  store i32 2, ptr %a, align 4
33  store i32 3, ptr %b, align 4
34  br label %next
35next:
36  store i32 2, ptr %output, align 4
37  store i32 3, ptr %result, align 4
38  ret void
39}
40; CHECK-LABEL: @outline_outputs1(
41; CHECK-NEXT:  entry:
42; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
43; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
44; CHECK-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 4
45; CHECK-NEXT:    [[RESULT:%.*]] = alloca i32, align 4
46; CHECK-NEXT:    [[OUTPUT2:%.*]] = alloca i32, align 4
47; CHECK-NEXT:    [[RESULT2:%.*]] = alloca i32, align 4
48; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[RESULT]])
49; CHECK-NEXT:    ret void
50;
51;
52; CHECK-LABEL: @outline_outputs2(
53; CHECK-NEXT:  entry:
54; CHECK-NEXT:    [[A:%.*]] = alloca i32, align 4
55; CHECK-NEXT:    [[B:%.*]] = alloca i32, align 4
56; CHECK-NEXT:    [[OUTPUT:%.*]] = alloca i32, align 4
57; CHECK-NEXT:    [[RESULT:%.*]] = alloca i32, align 4
58; CHECK-NEXT:    [[OUTPUT2:%.*]] = alloca i32, align 4
59; CHECK-NEXT:    [[RESULT2:%.*]] = alloca i32, align 4
60; CHECK-NEXT:    call void @outlined_ir_func_0(ptr [[A]], ptr [[B]], ptr [[OUTPUT]], ptr [[RESULT]])
61; CHECK-NEXT:    ret void
62;
63;
64; CHECK: define internal void @outlined_ir_func_0(
65; CHECK:  newFuncRoot:
66; CHECK-NEXT:    br label [[ENTRY_TO_OUTLINE:%.*]]
67; CHECK:       entry_to_outline:
68; CHECK-NEXT:    store i32 2, ptr [[TMP0:%.*]], align 4
69; CHECK-NEXT:    store i32 3, ptr [[TMP1:%.*]], align 4
70; CHECK-NEXT:    br label [[NEXT:%.*]]
71; CHECK:       next:
72; CHECK-NEXT:    store i32 2, ptr [[TMP2:%.*]], align 4
73; CHECK-NEXT:    store i32 3, ptr [[TMP3:%.*]], align 4
74; CHECK-NEXT:    br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]]
75; CHECK:       entry_after_outline.exitStub:
76; CHECK-NEXT:    ret void
77;
78