52 lines · plain
1; REQUIRES: asserts2; RUN: opt -passes=inline -mtriple=aarch64--linux-gnu -mcpu=kryo -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s3 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 void @outer1(ptr %ptr, i32 %i) {8 call void @inner1(ptr %ptr, i32 %i)9 ret void10}11 12define void @outer2(ptr %ptr, i32 %i) {13 call void @inner2(ptr %ptr, i32 %i)14 ret void15}16 17define void @outer3(ptr %ptr, i32 %j) {18 call void @inner3(ptr %ptr, i32 0, i32 %j)19 ret void20}21 22; The gep in inner1() is reg+reg, which is a legal addressing mode for AArch64.23; Thus, both the gep and ret can be simplified.24; CHECK: Analyzing call of inner125; CHECK: NumInstructionsSimplified: 226; CHECK: NumInstructions: 227define void @inner1(ptr %ptr, i32 %i) {28 %G = getelementptr inbounds [4 x i32], ptr %ptr, i32 0, i32 %i29 ret void30}31 32; The gep in inner2() is reg+imm+reg, which is not a legal addressing mode for33; AArch64. Thus, only the ret can be simplified and not the gep.34; CHECK: Analyzing call of inner235; CHECK: NumInstructionsSimplified: 136; CHECK: NumInstructions: 237define void @inner2(ptr %ptr, i32 %i) {38 %G = getelementptr inbounds [4 x i32], ptr %ptr, i32 1, i32 %i39 ret void40}41 42; The gep in inner3() is reg+reg because %i is a known constant from the43; callsite. This case is a legal addressing mode for AArch64. Thus, both the44; gep and ret can be simplified.45; CHECK: Analyzing call of inner346; CHECK: NumInstructionsSimplified: 247; CHECK: NumInstructions: 248define void @inner3(ptr %ptr, i32 %i, i32 %j) {49 %G = getelementptr inbounds [4 x i32], ptr %ptr, i32 %i, i32 %j50 ret void51}52