File: machine-outliner-leaf-descendants.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (124 lines) | stat: -rw-r--r-- 4,786 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
; This test is mainly for the -outliner-leaf-descendants flag for MachineOutliner.
;
; ===================== -outliner-leaf-descendants=false =====================
; MachineOutliner finds THREE key `OutlinedFunction` and outlines them. They are:
;   ```
;     mov     w0, #1
;     mov     w1, #2
;     mov     w2, #3
;     mov     w3, #4
;     mov     w4, #5
;     mov     w5, #6 or #7 or #8
;     b
;   ```
; Each has:
;   - `SequenceSize=28` and `OccurrenceCount=2`
;   - each Candidate has `CallOverhead=4` and `FrameOverhead=0`
;   - `NotOutlinedCost=28*2=56` and `OutliningCost=4*2+28+0=36`
;   - `Benefit=56-36=20` and `Priority=56/36=1.56`
;
; ===================== -outliner-leaf-descendants=true =====================
; MachineOutliner finds a FOURTH key `OutlinedFunction`, which is:
;   ```
;   mov     w0, #1
;   mov     w1, #2
;   mov     w2, #3
;   mov     w3, #4
;   mov     w4, #5
;   ```
; This corresponds to an internal node that has ZERO leaf children, but SIX leaf descendants.
; It has:
;   - `SequenceSize=20` and `OccurrenceCount=6`
;   - each Candidate has `CallOverhead=12` and `FrameOverhead=4`
;   - `NotOutlinedCost=20*6=120` and `OutliningCost=12*6+20+4=96`
;   - `Benefit=120-96=24` and `Priority=120/96=1.25`
;
; The FOURTH `OutlinedFunction` has lower _priority_ compared to the first THREE `OutlinedFunction`.
; Hence, we use `-outliner-benefit-threshold=22` to check if the FOURTH `OutlinedFunction` is identified.

; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -filetype=obj -o %t
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE

; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=false -outliner-benefit-threshold=22 -filetype=obj -o %t
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-NO-CANDIDATE

; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -filetype=obj -o %t
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-BASELINE

; RUN: llc %s -enable-machine-outliner=always -outliner-leaf-descendants=true -outliner-benefit-threshold=22 -filetype=obj -o %t
; RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=CHECK-LEAF-DESCENDANTS


target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
target triple = "arm64-apple-macosx14.0.0"

declare i32 @_Z3fooiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef)

define i32 @_Z2f1v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)
  ret i32 %1
}

define i32 @_Z2f2v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 6)
  ret i32 %1
}

define i32 @_Z2f3v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)
  ret i32 %1
}

define i32 @_Z2f4v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 7)
  ret i32 %1
}

define i32 @_Z2f5v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)
  ret i32 %1
}

define i32 @_Z2f6v() minsize {
  %1 = tail call i32 @_Z3fooiiii(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i32 noundef 8)
  ret i32 %1
}

; CHECK-BASELINE: <_OUTLINED_FUNCTION_0>:
; CHECK-BASELINE-NEXT: mov     w0, #0x1
; CHECK-BASELINE-NEXT: mov     w1, #0x2
; CHECK-BASELINE-NEXT: mov     w2, #0x3
; CHECK-BASELINE-NEXT: mov     w3, #0x4
; CHECK-BASELINE-NEXT: mov     w4, #0x5
; CHECK-BASELINE-NEXT: mov     w5, #0x6
; CHECK-BASELINE-NEXT: b

; CHECK-BASELINE: <_OUTLINED_FUNCTION_1>:
; CHECK-BASELINE-NEXT: mov     w0, #0x1
; CHECK-BASELINE-NEXT: mov     w1, #0x2
; CHECK-BASELINE-NEXT: mov     w2, #0x3
; CHECK-BASELINE-NEXT: mov     w3, #0x4
; CHECK-BASELINE-NEXT: mov     w4, #0x5
; CHECK-BASELINE-NEXT: mov     w5, #0x8
; CHECK-BASELINE-NEXT: b

; CHECK-BASELINE: <_OUTLINED_FUNCTION_2>:
; CHECK-BASELINE-NEXT: mov     w0, #0x1
; CHECK-BASELINE-NEXT: mov     w1, #0x2
; CHECK-BASELINE-NEXT: mov     w2, #0x3
; CHECK-BASELINE-NEXT: mov     w3, #0x4
; CHECK-BASELINE-NEXT: mov     w4, #0x5
; CHECK-BASELINE-NEXT: mov     w5, #0x7
; CHECK-BASELINE-NEXT: b

; CHECK-LEAF-DESCENDANTS: <_OUTLINED_FUNCTION_0>:
; CHECK-LEAF-DESCENDANTS-NEXT: mov     w0, #0x1
; CHECK-LEAF-DESCENDANTS-NEXT: mov     w1, #0x2
; CHECK-LEAF-DESCENDANTS-NEXT: mov     w2, #0x3
; CHECK-LEAF-DESCENDANTS-NEXT: mov     w3, #0x4
; CHECK-LEAF-DESCENDANTS-NEXT: mov     w4, #0x5
; CHECK-LEAF-DESCENDANTS-NEXT: ret

; CHECK-LEAF-DESCENDANTS-NOT: <_OUTLINED_FUNCTION_1>:

; CHECK-NO-CANDIDATE-NOT: <_OUTLINED_FUNCTION_0>: