1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.8.0 -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=throughput -mcpu=corei7-avx | FileCheck %s --check-prefix=THRU
3 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.8.0 -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=latency -mcpu=corei7-avx | FileCheck %s --check-prefix=LATE
4 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.8.0 -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=code-size -mcpu=corei7-avx | FileCheck %s --check-prefix=SIZE
5 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.8.0 -passes="print<cost-model>" 2>&1 -disable-output -cost-kind=size-latency -mcpu=corei7-avx | FileCheck %s --check-prefix=SIZE_LATE
7 define void @test_geps() {
8 ; THRU-LABEL: 'test_geps'
9 ; THRU-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %giant_gep0 = getelementptr inbounds i8, ptr undef, i64 9223372036854775807
10 ; THRU-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %giant_gep1 = getelementptr inbounds i8, ptr undef, i128 295147905179352825855
11 ; THRU-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
13 ; LATE-LABEL: 'test_geps'
14 ; LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %giant_gep0 = getelementptr inbounds i8, ptr undef, i64 9223372036854775807
15 ; LATE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %giant_gep1 = getelementptr inbounds i8, ptr undef, i128 295147905179352825855
16 ; LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
18 ; SIZE-LABEL: 'test_geps'
19 ; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %giant_gep0 = getelementptr inbounds i8, ptr undef, i64 9223372036854775807
20 ; SIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %giant_gep1 = getelementptr inbounds i8, ptr undef, i128 295147905179352825855
21 ; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
23 ; SIZE_LATE-LABEL: 'test_geps'
24 ; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %giant_gep0 = getelementptr inbounds i8, ptr undef, i64 9223372036854775807
25 ; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %giant_gep1 = getelementptr inbounds i8, ptr undef, i128 295147905179352825855
26 ; SIZE_LATE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void
29 ; Cost of scalar geps should be zero.
30 ; We expect it to be folded into the instruction addressing mode.
33 ; Vector geps should also have zero cost.
35 ; Check that we handle outlandishly large GEPs properly. This is unlikely to
36 ; be a valid pointer, but LLVM still generates GEPs like this sometimes in
38 ; This GEP has index INT64_MAX, which is cost 1.
39 %giant_gep0 = getelementptr inbounds i8, ptr undef, i64 9223372036854775807
41 ; This GEP index wraps around to -1, which is cost 0.
42 %giant_gep1 = getelementptr inbounds i8, ptr undef, i128 295147905179352825855