1; REQUIRES: asserts 2; RUN: opt -inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s 3 4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 5target triple = "aarch64--linux-gnu" 6 7define i32 @outer1(i32* %ptr, i32 %i) { 8 %C = call i32 @inner1(i32* %ptr, i32 %i) 9 ret i32 %C 10} 11 12; sext can be folded into gep. 13; CHECK: Analyzing call of inner1 14; CHECK: NumInstructionsSimplified: 3 15; CHECK: NumInstructions: 4 16define 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 20 ret i32 %L 21} 22 23define i32 @outer2(i32* %ptr, i32 %i) { 24 %C = call i32 @inner2(i32* %ptr, i32 %i) 25 ret i32 %C 26} 27 28; zext from i32 to i64 is free. 29; CHECK: Analyzing call of inner2 30; CHECK: NumInstructionsSimplified: 3 31; CHECK: NumInstructions: 4 32define 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 36 ret i32 %L 37} 38 39define i32 @outer3(i32* %ptr, i16 %i) { 40 %C = call i32 @inner3(i32* %ptr, i16 %i) 41 ret i32 %C 42} 43 44; zext can be folded into gep. 45; CHECK: Analyzing call of inner3 46; CHECK: NumInstructionsSimplified: 3 47; CHECK: NumInstructions: 4 48define 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 52 ret i32 %L 53} 54 55define i16 @outer4(i8* %ptr) { 56 %C = call i16 @inner4(i8* %ptr) 57 ret i16 %C 58} 59 60; It is an ExtLoad. 61; CHECK: Analyzing call of inner4 62; CHECK: NumInstructionsSimplified: 2 63; CHECK: NumInstructions: 3 64define i16 @inner4(i8* %ptr) { 65 %L = load i8, i8* %ptr 66 %E = zext i8 %L to i16 67 ret i16 %E 68} 69 70define i16 @outer5(i8* %ptr) { 71 %C = call i16 @inner5(i8* %ptr) 72 ret i16 %C 73} 74 75; It is an ExtLoad. 76; CHECK: Analyzing call of inner5 77; CHECK: NumInstructionsSimplified: 2 78; CHECK: NumInstructions: 3 79define i16 @inner5(i8* %ptr) { 80 %L = load i8, i8* %ptr 81 %E = sext i8 %L to i16 82 ret i16 %E 83} 84 85define i32 @outer6(i8* %ptr) { 86 %C = call i32 @inner6(i8* %ptr) 87 ret i32 %C 88} 89 90; It is an ExtLoad. 91; CHECK: Analyzing call of inner6 92; CHECK: NumInstructionsSimplified: 2 93; CHECK: NumInstructions: 3 94define i32 @inner6(i8* %ptr) { 95 %L = load i8, i8* %ptr 96 %E = zext i8 %L to i32 97 ret i32 %E 98} 99 100define i32 @outer7(i8* %ptr) { 101 %C = call i32 @inner7(i8* %ptr) 102 ret i32 %C 103} 104 105; It is an ExtLoad. 106; CHECK: Analyzing call of inner7 107; CHECK: NumInstructionsSimplified: 2 108; CHECK: NumInstructions: 3 109define i32 @inner7(i8* %ptr) { 110 %L = load i8, i8* %ptr 111 %E = sext i8 %L to i32 112 ret i32 %E 113} 114 115define i32 @outer8(i16* %ptr) { 116 %C = call i32 @inner8(i16* %ptr) 117 ret i32 %C 118} 119 120; It is an ExtLoad. 121; CHECK: Analyzing call of inner8 122; CHECK: NumInstructionsSimplified: 2 123; CHECK: NumInstructions: 3 124define i32 @inner8(i16* %ptr) { 125 %L = load i16, i16* %ptr 126 %E = zext i16 %L to i32 127 ret i32 %E 128} 129 130define i32 @outer9(i16* %ptr) { 131 %C = call i32 @inner9(i16* %ptr) 132 ret i32 %C 133} 134 135; It is an ExtLoad. 136; CHECK: Analyzing call of inner9 137; CHECK: NumInstructionsSimplified: 2 138; CHECK: NumInstructions: 3 139define i32 @inner9(i16* %ptr) { 140 %L = load i16, i16* %ptr 141 %E = sext i16 %L to i32 142 ret i32 %E 143} 144 145define i64 @outer10(i8* %ptr) { 146 %C = call i64 @inner10(i8* %ptr) 147 ret i64 %C 148} 149 150; It is an ExtLoad. 151; CHECK: Analyzing call of inner10 152; CHECK: NumInstructionsSimplified: 2 153; CHECK: NumInstructions: 3 154define i64 @inner10(i8* %ptr) { 155 %L = load i8, i8* %ptr 156 %E = zext i8 %L to i64 157 ret i64 %E 158} 159 160define i64 @outer11(i8* %ptr) { 161 %C = call i64 @inner11(i8* %ptr) 162 ret i64 %C 163} 164 165; It is an ExtLoad. 166; CHECK: Analyzing call of inner11 167; CHECK: NumInstructionsSimplified: 2 168; CHECK: NumInstructions: 3 169define i64 @inner11(i8* %ptr) { 170 %L = load i8, i8* %ptr 171 %E = sext i8 %L to i64 172 ret i64 %E 173} 174 175define i64 @outer12(i16* %ptr) { 176 %C = call i64 @inner12(i16* %ptr) 177 ret i64 %C 178} 179 180; It is an ExtLoad. 181; CHECK: Analyzing call of inner12 182; CHECK: NumInstructionsSimplified: 2 183; CHECK: NumInstructions: 3 184define i64 @inner12(i16* %ptr) { 185 %L = load i16, i16* %ptr 186 %E = zext i16 %L to i64 187 ret i64 %E 188} 189 190define i64 @outer13(i16* %ptr) { 191 %C = call i64 @inner13(i16* %ptr) 192 ret i64 %C 193} 194 195; It is an ExtLoad. 196; CHECK: Analyzing call of inner13 197; CHECK: NumInstructionsSimplified: 2 198; CHECK: NumInstructions: 3 199define i64 @inner13(i16* %ptr) { 200 %L = load i16, i16* %ptr 201 %E = sext i16 %L to i64 202 ret i64 %E 203} 204 205define i64 @outer14(i32* %ptr) { 206 %C = call i64 @inner14(i32* %ptr) 207 ret i64 %C 208} 209 210; It is an ExtLoad. 211; CHECK: Analyzing call of inner14 212; CHECK: NumInstructionsSimplified: 2 213; CHECK: NumInstructions: 3 214define i64 @inner14(i32* %ptr) { 215 %L = load i32, i32* %ptr 216 %E = zext i32 %L to i64 217 ret i64 %E 218} 219 220define i64 @outer15(i32* %ptr) { 221 %C = call i64 @inner15(i32* %ptr) 222 ret i64 %C 223} 224 225; It is an ExtLoad. 226; CHECK: Analyzing call of inner15 227; CHECK: NumInstructionsSimplified: 2 228; CHECK: NumInstructions: 3 229define i64 @inner15(i32* %ptr) { 230 %L = load i32, i32* %ptr 231 %E = sext i32 %L to i64 232 ret i64 %E 233} 234 235define i64 @outer16(i32 %V1, i64 %V2) { 236 %C = call i64 @inner16(i32 %V1, i64 %V2) 237 ret i64 %C 238} 239 240; sext can be folded into shl. 241; CHECK: Analyzing call of inner16 242; CHECK: NumInstructionsSimplified: 2 243; CHECK: NumInstructions: 4 244define i64 @inner16(i32 %V1, i64 %V2) { 245 %E = sext i32 %V1 to i64 246 %S = shl i64 %E, 3 247 %A = add i64 %V2, %S 248 ret i64 %A 249} 250