Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 0b6e684

Browse files
author
Haicheng Wu
committed
[InlineCost] Add a test case for GEP cost
The added test case is to check whether the simplified value is passed to getGEPCost(). Differential Revision: https://reviews.llvm.org/D33779 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304454 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4edf255 commit 0b6e684

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

test/Transforms/Inline/AArch64/gep-cost.ll

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@
44
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
55
target triple = "aarch64--linux-gnu"
66

7-
define void @outer([4 x i32]* %ptr, i32 %i) {
7+
define void @outer1([4 x i32]* %ptr, i32 %i) {
88
call void @inner1([4 x i32]* %ptr, i32 %i)
9+
ret void
10+
}
11+
12+
define void @outer2([4 x i32]* %ptr, i32 %i) {
913
call void @inner2([4 x i32]* %ptr, i32 %i)
1014
ret void
1115
}
16+
17+
define 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+
1222
; The gep in inner1() is reg+reg, which is a legal addressing mode for AArch64.
1323
; Thus, both the gep and ret can be simplified.
1424
; CHECK: Analyzing call of inner1
@@ -19,7 +29,7 @@ define void @inner1([4 x i32]* %ptr, i32 %i) {
1929
ret void
2030
}
2131

22-
; The gep in inner2() is reg+imm+reg, which is not a legal addressing mode for
32+
; The gep in inner2() is reg+imm+reg, which is not a legal addressing mode for
2333
; AArch64. Thus, only the ret can be simplified and not the gep.
2434
; CHECK: Analyzing call of inner2
2535
; CHECK: NumInstructionsSimplified: 1
@@ -28,3 +38,14 @@ define void @inner2([4 x i32]* %ptr, i32 %i) {
2838
%G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 1, i32 %i
2939
ret void
3040
}
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
48+
define 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+
}

0 commit comments

Comments
 (0)