Skip to content

Commit 53ba428

Browse files
committed
Add testcase for outlining leaf descendants
Adapted from AArch64/machine-outliner-leaf-descendants.ll Towards: #114437
1 parent 88591aa commit 53ba428

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
; This test is mainly for the -outliner-leaf-descendants flag for MachineOutliner.
2+
;
3+
; ===================== -outliner-leaf-descendants=false =====================
4+
; MachineOutliner finds THREE key `OutlinedFunction` and outlines them. They are:
5+
; ```
6+
; mov w0, #1
7+
; mov w1, #2
8+
; mov w2, #3
9+
; mov w3, #4
10+
; mov w4, #5
11+
; mov w5, #6 or #7 or #8
12+
; b
13+
; ```
14+
; Each has:
15+
; - `SequenceSize=28` and `OccurrenceCount=2`
16+
; - each Candidate has `CallOverhead=4` and `FrameOverhead=0`
17+
; - `NotOutlinedCost=28*2=56` and `OutliningCost=4*2+28+0=36`
18+
; - `Benefit=56-36=20` and `Priority=56/36=1.56`
19+
;
20+
; ===================== -outliner-leaf-descendants=true =====================
21+
; MachineOutliner finds a FOURTH key `OutlinedFunction`, which is:
22+
; ```
23+
; mov w0, #1
24+
; mov w1, #2
25+
; mov w2, #3
26+
; mov w3, #4
27+
; mov w4, #5
28+
; ```
29+
; This corresponds to an internal node that has ZERO leaf children, but SIX leaf descendants.
30+
; It has:
31+
; - `SequenceSize=20` and `OccurrenceCount=6`
32+
; - each Candidate has `CallOverhead=12` and `FrameOverhead=4`
33+
; - `NotOutlinedCost=20*6=120` and `OutliningCost=12*6+20+4=96`
34+
; - `Benefit=120-96=24` and `Priority=120/96=1.25`
35+
;
36+
; The FOURTH `OutlinedFunction` has lower _priority_ compared to the first THREE `OutlinedFunction`.
37+
; Hence, we use `-outliner-benefit-threshold=22` to check if the FOURTH `OutlinedFunction` is identified.
38+
39+
; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -mattr=+m -mtriple=riscv64 -filetype=obj -o %t
40+
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE
41+
42+
; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -mattr=+m -mtriple=riscv64 -outliner-benefit-threshold=22 -filetype=obj -o %t
43+
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-NO-CANDIDATE
44+
45+
; : llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -mattr=+m -mtriple=riscv64 -filetype=obj -o %t
46+
; : llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE
47+
48+
; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -mattr=+m -mtriple=riscv64 -outliner-benefit-threshold=22 -filetype=obj -o %t
49+
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-LEAF-DESCENDANTS
50+
51+
52+
declare i32 @_Z3fooiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef)
53+
54+
define i32 @_Z2f1v() minsize {
55+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)
56+
ret i32 %1
57+
}
58+
59+
define i32 @_Z2f2v() minsize {
60+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)
61+
ret i32 %1
62+
}
63+
64+
define i32 @_Z2f3v() minsize {
65+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)
66+
ret i32 %1
67+
}
68+
69+
define i32 @_Z2f4v() minsize {
70+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)
71+
ret i32 %1
72+
}
73+
74+
define i32 @_Z2f5v() minsize {
75+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)
76+
ret i32 %1
77+
}
78+
79+
define i32 @_Z2f6v() minsize {
80+
%1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)
81+
ret i32 %1
82+
}
83+
84+
; CHECK-BASELINE: <OUTLINED_FUNCTION_0>:
85+
; CHECK-BASELINE-NEXT: li a0, 0x1
86+
; CHECK-BASELINE-NEXT: li a1, 0x2
87+
; CHECK-BASELINE-NEXT: li a2, 0x3
88+
; CHECK-BASELINE-NEXT: li a3, 0x4
89+
; CHECK-BASELINE-NEXT: li a4, 0x5
90+
; CHECK-BASELINE-NEXT: li a5, 0x6
91+
; CHECK-BASELINE-NEXT: jr t0
92+
93+
; CHECK-BASELINE: <OUTLINED_FUNCTION_1>:
94+
; CHECK-BASELINE-NEXT: li a0, 0x1
95+
; CHECK-BASELINE-NEXT: li a1, 0x2
96+
; CHECK-BASELINE-NEXT: li a2, 0x3
97+
; CHECK-BASELINE-NEXT: li a3, 0x4
98+
; CHECK-BASELINE-NEXT: li a4, 0x5
99+
; CHECK-BASELINE-NEXT: li a5, 0x7
100+
; CHECK-BASELINE-NEXT: jr t0
101+
102+
; CHECK-BASELINE: <OUTLINED_FUNCTION_2>:
103+
; CHECK-BASELINE-NEXT: li a0, 0x1
104+
; CHECK-BASELINE-NEXT: li a1, 0x2
105+
; CHECK-BASELINE-NEXT: li a2, 0x3
106+
; CHECK-BASELINE-NEXT: li a3, 0x4
107+
; CHECK-BASELINE-NEXT: li a4, 0x5
108+
; CHECK-BASELINE-NEXT: li a5, 0x8
109+
; CHECK-BASELINE-NEXT: jr t0
110+
111+
; CHECK-LEAF-DESCENDANTS: <OUTLINED_FUNCTION_0>:
112+
; CHECK-LEAF-DESCENDANTS-NEXT: li a0, 0x1
113+
; CHECK-LEAF-DESCENDANTS-NEXT: li a1, 0x2
114+
; CHECK-LEAF-DESCENDANTS-NEXT: li a2, 0x3
115+
; CHECK-LEAF-DESCENDANTS-NEXT: li a3, 0x4
116+
; CHECK-LEAF-DESCENDANTS-NEXT: li a4, 0x5
117+
; CHECK-LEAF-DESCENDANTS-NEXT: jr t0
118+
119+
; CHECK-LEAF-DESCENDANTS-NOT: <OUTLINED_FUNCTION_1>:
120+
121+
; CHECK-NO-CANDIDATE-NOT: <OUTLINED_FUNCTION_0>:

0 commit comments

Comments
 (0)