2 ; RUN: opt -inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64--linux-gnu"
7 define i32 @outer1(i32* %ptr, i32 %i) {
8 %C = call i32 @inner1(i32* %ptr, i32 %i)
12 ; sext can be folded into gep.
13 ; CHECK: Analyzing call of inner1
14 ; CHECK: NumInstructionsSimplified: 3
15 ; CHECK: NumInstructions: 4
16 define i32 @inner1(i32* %ptr, i32 %i) {
17 %E = sext i32 %i to i64
18 %G = getelementptr inbounds i32, i32* %ptr, i64 %E
19 %L = load i32, i32* %G
23 define i32 @outer2(i32* %ptr, i32 %i) {
24 %C = call i32 @inner2(i32* %ptr, i32 %i)
28 ; zext from i32 to i64 is free.
29 ; CHECK: Analyzing call of inner2
30 ; CHECK: NumInstructionsSimplified: 3
31 ; CHECK: NumInstructions: 4
32 define i32 @inner2(i32* %ptr, i32 %i) {
33 %E = zext i32 %i to i64
34 %G = getelementptr inbounds i32, i32* %ptr, i64 %E
35 %L = load i32, i32* %G
39 define i32 @outer3(i32* %ptr, i16 %i) {
40 %C = call i32 @inner3(i32* %ptr, i16 %i)
44 ; zext can be folded into gep.
45 ; CHECK: Analyzing call of inner3
46 ; CHECK: NumInstructionsSimplified: 3
47 ; CHECK: NumInstructions: 4
48 define i32 @inner3(i32* %ptr, i16 %i) {
49 %E = zext i16 %i to i64
50 %G = getelementptr inbounds i32, i32* %ptr, i64 %E
51 %L = load i32, i32* %G
55 define i16 @outer4(i8* %ptr) {
56 %C = call i16 @inner4(i8* %ptr)
61 ; CHECK: Analyzing call of inner4
62 ; CHECK: NumInstructionsSimplified: 2
63 ; CHECK: NumInstructions: 3
64 define i16 @inner4(i8* %ptr) {
65 %L = load i8, i8* %ptr
66 %E = zext i8 %L to i16
70 define i16 @outer5(i8* %ptr) {
71 %C = call i16 @inner5(i8* %ptr)
76 ; CHECK: Analyzing call of inner5
77 ; CHECK: NumInstructionsSimplified: 2
78 ; CHECK: NumInstructions: 3
79 define i16 @inner5(i8* %ptr) {
80 %L = load i8, i8* %ptr
81 %E = sext i8 %L to i16
85 define i32 @outer6(i8* %ptr) {
86 %C = call i32 @inner6(i8* %ptr)
91 ; CHECK: Analyzing call of inner6
92 ; CHECK: NumInstructionsSimplified: 2
93 ; CHECK: NumInstructions: 3
94 define i32 @inner6(i8* %ptr) {
95 %L = load i8, i8* %ptr
96 %E = zext i8 %L to i32
100 define i32 @outer7(i8* %ptr) {
101 %C = call i32 @inner7(i8* %ptr)
106 ; CHECK: Analyzing call of inner7
107 ; CHECK: NumInstructionsSimplified: 2
108 ; CHECK: NumInstructions: 3
109 define i32 @inner7(i8* %ptr) {
110 %L = load i8, i8* %ptr
111 %E = sext i8 %L to i32
115 define i32 @outer8(i16* %ptr) {
116 %C = call i32 @inner8(i16* %ptr)
121 ; CHECK: Analyzing call of inner8
122 ; CHECK: NumInstructionsSimplified: 2
123 ; CHECK: NumInstructions: 3
124 define i32 @inner8(i16* %ptr) {
125 %L = load i16, i16* %ptr
126 %E = zext i16 %L to i32
130 define i32 @outer9(i16* %ptr) {
131 %C = call i32 @inner9(i16* %ptr)
136 ; CHECK: Analyzing call of inner9
137 ; CHECK: NumInstructionsSimplified: 2
138 ; CHECK: NumInstructions: 3
139 define i32 @inner9(i16* %ptr) {
140 %L = load i16, i16* %ptr
141 %E = sext i16 %L to i32
145 define i64 @outer10(i8* %ptr) {
146 %C = call i64 @inner10(i8* %ptr)
151 ; CHECK: Analyzing call of inner10
152 ; CHECK: NumInstructionsSimplified: 2
153 ; CHECK: NumInstructions: 3
154 define i64 @inner10(i8* %ptr) {
155 %L = load i8, i8* %ptr
156 %E = zext i8 %L to i64
160 define i64 @outer11(i8* %ptr) {
161 %C = call i64 @inner11(i8* %ptr)
166 ; CHECK: Analyzing call of inner11
167 ; CHECK: NumInstructionsSimplified: 2
168 ; CHECK: NumInstructions: 3
169 define i64 @inner11(i8* %ptr) {
170 %L = load i8, i8* %ptr
171 %E = sext i8 %L to i64
175 define i64 @outer12(i16* %ptr) {
176 %C = call i64 @inner12(i16* %ptr)
181 ; CHECK: Analyzing call of inner12
182 ; CHECK: NumInstructionsSimplified: 2
183 ; CHECK: NumInstructions: 3
184 define i64 @inner12(i16* %ptr) {
185 %L = load i16, i16* %ptr
186 %E = zext i16 %L to i64
190 define i64 @outer13(i16* %ptr) {
191 %C = call i64 @inner13(i16* %ptr)
196 ; CHECK: Analyzing call of inner13
197 ; CHECK: NumInstructionsSimplified: 2
198 ; CHECK: NumInstructions: 3
199 define i64 @inner13(i16* %ptr) {
200 %L = load i16, i16* %ptr
201 %E = sext i16 %L to i64
205 define i64 @outer14(i32* %ptr) {
206 %C = call i64 @inner14(i32* %ptr)
211 ; CHECK: Analyzing call of inner14
212 ; CHECK: NumInstructionsSimplified: 2
213 ; CHECK: NumInstructions: 3
214 define i64 @inner14(i32* %ptr) {
215 %L = load i32, i32* %ptr
216 %E = zext i32 %L to i64
220 define i64 @outer15(i32* %ptr) {
221 %C = call i64 @inner15(i32* %ptr)
226 ; CHECK: Analyzing call of inner15
227 ; CHECK: NumInstructionsSimplified: 2
228 ; CHECK: NumInstructions: 3
229 define i64 @inner15(i32* %ptr) {
230 %L = load i32, i32* %ptr
231 %E = sext i32 %L to i64
235 define i64 @outer16(i32 %V1, i64 %V2) {
236 %C = call i64 @inner16(i32 %V1, i64 %V2)
240 ; sext can be folded into shl.
241 ; CHECK: Analyzing call of inner16
242 ; CHECK: NumInstructionsSimplified: 2
243 ; CHECK: NumInstructions: 4
244 define i64 @inner16(i32 %V1, i64 %V2) {
245 %E = sext i32 %V1 to i64