1; REQUIRES: asserts 2; RUN: opt -inline -mtriple=aarch64--linux-gnu -mcpu=kryo -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 void @outer1([4 x i32]* %ptr, i32 %i) { 8 call void @inner1([4 x i32]* %ptr, i32 %i) 9 ret void 10} 11 12define void @outer2([4 x i32]* %ptr, i32 %i) { 13 call void @inner2([4 x i32]* %ptr, i32 %i) 14 ret void 15} 16 17define void @outer3([4 x i32]* %ptr, i32 %j) { 18 call void @inner3([4 x i32]* %ptr, i32 0, i32 %j) 19 ret void 20} 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 inner1 25; CHECK: NumInstructionsSimplified: 2 26; CHECK: NumInstructions: 2 27define void @inner1([4 x i32]* %ptr, i32 %i) { 28 %G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 0, i32 %i 29 ret void 30} 31 32; The gep in inner2() is reg+imm+reg, which is not a legal addressing mode for 33; AArch64. Thus, only the ret can be simplified and not the gep. 34; CHECK: Analyzing call of inner2 35; CHECK: NumInstructionsSimplified: 1 36; CHECK: NumInstructions: 2 37define void @inner2([4 x i32]* %ptr, i32 %i) { 38 %G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 1, i32 %i 39 ret void 40} 41 42; The gep in inner3() is reg+reg because %i is a known constant from the 43; callsite. This case is a legal addressing mode for AArch64. Thus, both the 44; gep and ret can be simplified. 45; CHECK: Analyzing call of inner3 46; CHECK: NumInstructionsSimplified: 2 47; CHECK: NumInstructions: 2 48define void @inner3([4 x i32]* %ptr, i32 %i, i32 %j) { 49 %G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 %i, i32 %j 50 ret void 51} 52