xref: /aosp_15_r20/external/llvm/test/Analysis/CostModel/ARM/gep.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -cost-model -analyze -mtriple=thumbv7-apple-ios6.0.0 -mcpu=swift < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
4*9880d681SAndroid Build Coastguard Workertarget triple = "thumbv7-apple-ios6.0.0"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine void @test_geps(i32 %i) {
7*9880d681SAndroid Build Coastguard Worker  ; GEPs with index 0 are essentially NOOPs.
8*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
9*9880d681SAndroid Build Coastguard Worker  %a0 = getelementptr inbounds i8, i8* undef, i32 0
10*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
11*9880d681SAndroid Build Coastguard Worker  %a1 = getelementptr inbounds i16, i16* undef, i32 0
12*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
13*9880d681SAndroid Build Coastguard Worker  %a2 = getelementptr inbounds i32, i32* undef, i32 0
14*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
15*9880d681SAndroid Build Coastguard Worker  %a3 = getelementptr inbounds i64, i64* undef, i32 0
16*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds float, float*
17*9880d681SAndroid Build Coastguard Worker  %a4 = getelementptr inbounds float, float* undef, i32 0
18*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds double, double*
19*9880d681SAndroid Build Coastguard Worker  %a5 = getelementptr inbounds double, double* undef, i32 0
20*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i8>, <4 x i8>*
21*9880d681SAndroid Build Coastguard Worker  %a7 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 0
22*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i16>, <4 x i16>*
23*9880d681SAndroid Build Coastguard Worker  %a8 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 0
24*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i32>, <4 x i32>*
25*9880d681SAndroid Build Coastguard Worker  %a9 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 0
26*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i64>, <4 x i64>*
27*9880d681SAndroid Build Coastguard Worker  %a10 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 0
28*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x float>, <4 x float>*
29*9880d681SAndroid Build Coastguard Worker  %a11 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 0
30*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x double>, <4 x double>*
31*9880d681SAndroid Build Coastguard Worker  %a12 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 0
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Worker  ; Cost of GEPs is one if we cannot fold the address computation.
34*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
35*9880d681SAndroid Build Coastguard Worker  %b0 = getelementptr inbounds i8, i8* undef, i32 1024
36*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
37*9880d681SAndroid Build Coastguard Worker  %b1 = getelementptr inbounds i16, i16* undef, i32 1024
38*9880d681SAndroid Build Coastguard Worker  ; Thumb-2 cannot fold offset >= 2^12 into address computation.
39*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
40*9880d681SAndroid Build Coastguard Worker  %b2 = getelementptr inbounds i32, i32* undef, i32 1024
41*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
42*9880d681SAndroid Build Coastguard Worker  %b3 = getelementptr inbounds i64, i64* undef, i32 1024
43*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds float, float*
44*9880d681SAndroid Build Coastguard Worker  %b4 = getelementptr inbounds float, float* undef, i32 1024
45*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds double, double*
46*9880d681SAndroid Build Coastguard Worker  %b5 = getelementptr inbounds double, double* undef, i32 1024
47*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i8>, <4 x i8>*
48*9880d681SAndroid Build Coastguard Worker  %b7 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 1
49*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i16>, <4 x i16>*
50*9880d681SAndroid Build Coastguard Worker  %b8 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 1
51*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i32>, <4 x i32>*
52*9880d681SAndroid Build Coastguard Worker  %b9 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 1
53*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i64>, <4 x i64>*
54*9880d681SAndroid Build Coastguard Worker  %b10 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 1
55*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x float>, <4 x float>*
56*9880d681SAndroid Build Coastguard Worker  %b11 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 1
57*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x double>, <4 x double>*
58*9880d681SAndroid Build Coastguard Worker  %b12 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 1
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
61*9880d681SAndroid Build Coastguard Worker  %c0 = getelementptr inbounds i8, i8* undef, i32 %i
62*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
63*9880d681SAndroid Build Coastguard Worker  %c1 = getelementptr inbounds i16, i16* undef, i32 %i
64*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
65*9880d681SAndroid Build Coastguard Worker  %c2 = getelementptr inbounds i32, i32* undef, i32 %i
66*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
67*9880d681SAndroid Build Coastguard Worker  %c3 = getelementptr inbounds i64, i64* undef, i32 %i
68*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds float, float*
69*9880d681SAndroid Build Coastguard Worker  %c4 = getelementptr inbounds float, float* undef, i32 %i
70*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds double, double*
71*9880d681SAndroid Build Coastguard Worker  %c5 = getelementptr inbounds double, double* undef, i32 %i
72*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i8>, <4 x i8>*
73*9880d681SAndroid Build Coastguard Worker  %c7 = getelementptr inbounds <4 x i8>, <4 x i8>* undef, i32 %i
74*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds <4 x i16>, <4 x i16>*
75*9880d681SAndroid Build Coastguard Worker  %c8 = getelementptr inbounds <4 x i16>, <4 x i16>* undef, i32 %i
76*9880d681SAndroid Build Coastguard Worker  ; Thumb-2 cannot fold scales larger than 8 to address computation.
77*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds <4 x i32>, <4 x i32>*
78*9880d681SAndroid Build Coastguard Worker  %c9 = getelementptr inbounds <4 x i32>, <4 x i32>* undef, i32 %i
79*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds <4 x i64>, <4 x i64>*
80*9880d681SAndroid Build Coastguard Worker  %c10 = getelementptr inbounds <4 x i64>, <4 x i64>* undef, i32 %i
81*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds <4 x float>, <4 x float>*
82*9880d681SAndroid Build Coastguard Worker  %c11 = getelementptr inbounds <4 x float>, <4 x float>* undef, i32 %i
83*9880d681SAndroid Build Coastguard Worker;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds <4 x double>, <4 x double>*
84*9880d681SAndroid Build Coastguard Worker  %c12 = getelementptr inbounds <4 x double>, <4 x double>* undef, i32 %i
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Worker  ret void
87*9880d681SAndroid Build Coastguard Worker}
88