Cost model support for lowered math builtins.
[oota-llvm.git] / test / Analysis / CostModel / X86 / intrinsic-cost.ll
1 ; RUN: opt -S -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck %s -check-prefix=CORE2
2 ; RUN: opt -S -mtriple=x86_64-apple-darwin -mcpu=corei7 -cost-model -analyze < %s | FileCheck %s -check-prefix=COREI7
3
4 ; If SSE4.1 roundps instruction is available it is cheap to lower, otherwise
5 ; it'll be scalarized into calls which are expensive.
6 define void @test1(float* nocapture %f) nounwind {
7 vector.ph:
8   br label %vector.body
9
10 vector.body:                                      ; preds = %vector.body, %vector.ph
11   %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
12   %0 = getelementptr inbounds float* %f, i64 %index
13   %1 = bitcast float* %0 to <4 x float>*
14   %wide.load = load <4 x float>* %1, align 4
15   %2 = call <4 x float> @llvm.ceil.v4f32(<4 x float> %wide.load)
16   store <4 x float> %2, <4 x float>* %1, align 4
17   %index.next = add i64 %index, 4
18   %3 = icmp eq i64 %index.next, 1024
19   br i1 %3, label %for.end, label %vector.body
20
21 for.end:                                          ; preds = %vector.body
22   ret void
23
24 ; CORE2: Printing analysis 'Cost Model Analysis' for function 'test1':
25 ; CORE2: Cost Model: Found an estimated cost of 400 for instruction:   %2 = call <4 x float> @llvm.ceil.v4f32(<4 x float> %wide.load)
26
27 ; COREI7: Printing analysis 'Cost Model Analysis' for function 'test1':
28 ; COREI7: Cost Model: Found an estimated cost of 1 for instruction:   %2 = call <4 x float> @llvm.ceil.v4f32(<4 x float> %wide.load)
29
30 }
31
32 declare <4 x float> @llvm.ceil.v4f32(<4 x float>)  nounwind readnone