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