blob: ac14980bb0bcb067902953d627ca84f044975706 [file] [log] [blame]
Simon Pilgrim237730a2018-04-13 18:56:58 +00001; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
Guozhi Wei62d64142017-09-08 22:29:17 +00002; RUN: opt < %s -cost-model -cost-kind=latency -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=LATENCY
3; RUN: opt < %s -cost-model -cost-kind=code-size -analyze -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s --check-prefix=CODESIZE
4
5; Tests if the interface TargetTransformInfo::getInstructionCost() works correctly.
6
Guozhi Wei21f8fad2017-09-14 19:20:02 +00007target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
8
Guozhi Weibce228c2017-09-22 18:25:53 +00009declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32)
10
Guozhi Wei62d64142017-09-08 22:29:17 +000011define i64 @foo(i64 %arg) {
Simon Pilgrim237730a2018-04-13 18:56:58 +000012; LATENCY-LABEL: 'foo'
13; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %A1 = alloca i32, align 8
14; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %A2 = alloca i64, i64 undef, align 8
15; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %I64 = add i64 undef, undef
16; LATENCY-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %1 = load i64, i64* undef, align 4
17; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %BC = bitcast i8* undef to i32*
18; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %I2P = inttoptr i64 undef to i8*
19; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %P2I = ptrtoint i8* undef to i64
20; LATENCY-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %TC = trunc i64 undef to i32
21; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 undef, i32 undef)
22; LATENCY-NEXT: Cost Model: Found an estimated cost of 40 for instruction: call void undef()
23; LATENCY-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 undef
24;
25; CODESIZE-LABEL: 'foo'
26; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %A1 = alloca i32, align 8
27; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %A2 = alloca i64, i64 undef, align 8
28; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %I64 = add i64 undef, undef
29; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %1 = load i64, i64* undef, align 4
30; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %BC = bitcast i8* undef to i32*
31; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %I2P = inttoptr i64 undef to i8*
32; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %P2I = ptrtoint i8* undef to i64
33; CODESIZE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %TC = trunc i64 undef to i32
34; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 undef, i32 undef)
35; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: call void undef()
36; CODESIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 undef
37;
Guozhi Wei3d1305f2017-09-15 22:28:12 +000038 %A1 = alloca i32, align 8
Guozhi Wei3d1305f2017-09-15 22:28:12 +000039 %A2 = alloca i64, i64 undef, align 8
Guozhi Wei62d64142017-09-08 22:29:17 +000040 %I64 = add i64 undef, undef
Guozhi Wei62d64142017-09-08 22:29:17 +000041 load i64, i64* undef, align 4
Guozhi Wei21f8fad2017-09-14 19:20:02 +000042 %BC = bitcast i8* undef to i32*
Guozhi Wei21f8fad2017-09-14 19:20:02 +000043 %I2P = inttoptr i64 undef to i8*
Guozhi Wei21f8fad2017-09-14 19:20:02 +000044 %P2I = ptrtoint i8* undef to i64
Guozhi Wei21f8fad2017-09-14 19:20:02 +000045 %TC = trunc i64 undef to i32
Guozhi Weibce228c2017-09-22 18:25:53 +000046 %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 undef, i32 undef)
Guozhi Weieb301872017-10-04 20:14:08 +000047 call void undef()
Guozhi Wei62d64142017-09-08 22:29:17 +000048 ret i64 undef
49}