1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck %s -check-prefix=CORE2 2*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -mtriple=x86_64-apple-darwin -mcpu=corei7 -cost-model -analyze < %s | FileCheck %s -check-prefix=COREI7 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; If SSE4.1 roundps instruction is available it is cheap to lower, otherwise 5*9880d681SAndroid Build Coastguard Worker; it'll be scalarized into calls which are expensive. 6*9880d681SAndroid Build Coastguard Workerdefine void @test1(float* nocapture %f) nounwind { 7*9880d681SAndroid Build Coastguard Workervector.ph: 8*9880d681SAndroid Build Coastguard Worker br label %vector.body 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Workervector.body: ; preds = %vector.body, %vector.ph 11*9880d681SAndroid Build Coastguard Worker %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] 12*9880d681SAndroid Build Coastguard Worker %0 = getelementptr inbounds float, float* %f, i64 %index 13*9880d681SAndroid Build Coastguard Worker %1 = bitcast float* %0 to <4 x float>* 14*9880d681SAndroid Build Coastguard Worker %wide.load = load <4 x float>, <4 x float>* %1, align 4 15*9880d681SAndroid Build Coastguard Worker %2 = call <4 x float> @llvm.ceil.v4f32(<4 x float> %wide.load) 16*9880d681SAndroid Build Coastguard Worker store <4 x float> %2, <4 x float>* %1, align 4 17*9880d681SAndroid Build Coastguard Worker %index.next = add i64 %index, 4 18*9880d681SAndroid Build Coastguard Worker %3 = icmp eq i64 %index.next, 1024 19*9880d681SAndroid Build Coastguard Worker br i1 %3, label %for.end, label %vector.body 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %vector.body 22*9880d681SAndroid Build Coastguard Worker ret void 23*9880d681SAndroid Build Coastguard Worker 24*9880d681SAndroid Build Coastguard Worker; CORE2: Printing analysis 'Cost Model Analysis' for function 'test1': 25*9880d681SAndroid Build Coastguard Worker; CORE2: Cost Model: Found an estimated cost of 46 for instruction: %2 = call <4 x float> @llvm.ceil.v4f32(<4 x float> %wide.load) 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker; COREI7: Printing analysis 'Cost Model Analysis' for function 'test1': 28*9880d681SAndroid Build Coastguard Worker; 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*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard Worker} 31*9880d681SAndroid Build Coastguard Worker 32*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.ceil.v4f32(<4 x float>) nounwind readnone 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdefine void @test2(float* nocapture %f) nounwind { 35*9880d681SAndroid Build Coastguard Workervector.ph: 36*9880d681SAndroid Build Coastguard Worker br label %vector.body 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard Workervector.body: ; preds = %vector.body, %vector.ph 39*9880d681SAndroid Build Coastguard Worker %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] 40*9880d681SAndroid Build Coastguard Worker %0 = getelementptr inbounds float, float* %f, i64 %index 41*9880d681SAndroid Build Coastguard Worker %1 = bitcast float* %0 to <4 x float>* 42*9880d681SAndroid Build Coastguard Worker %wide.load = load <4 x float>, <4 x float>* %1, align 4 43*9880d681SAndroid Build Coastguard Worker %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) 44*9880d681SAndroid Build Coastguard Worker store <4 x float> %2, <4 x float>* %1, align 4 45*9880d681SAndroid Build Coastguard Worker %index.next = add i64 %index, 4 46*9880d681SAndroid Build Coastguard Worker %3 = icmp eq i64 %index.next, 1024 47*9880d681SAndroid Build Coastguard Worker br i1 %3, label %for.end, label %vector.body 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %vector.body 50*9880d681SAndroid Build Coastguard Worker ret void 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Worker; CORE2: Printing analysis 'Cost Model Analysis' for function 'test2': 53*9880d681SAndroid Build Coastguard Worker; CORE2: Cost Model: Found an estimated cost of 46 for instruction: %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker; COREI7: Printing analysis 'Cost Model Analysis' for function 'test2': 56*9880d681SAndroid Build Coastguard Worker; COREI7: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <4 x float> @llvm.nearbyint.v4f32(<4 x float> %wide.load) 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker} 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.nearbyint.v4f32(<4 x float>) nounwind readnone 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerdefine void @test3(float* nocapture %f, <4 x float> %b, <4 x float> %c) nounwind { 63*9880d681SAndroid Build Coastguard Workervector.ph: 64*9880d681SAndroid Build Coastguard Worker br label %vector.body 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Workervector.body: ; preds = %vector.body, %vector.ph 67*9880d681SAndroid Build Coastguard Worker %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] 68*9880d681SAndroid Build Coastguard Worker %0 = getelementptr inbounds float, float* %f, i64 %index 69*9880d681SAndroid Build Coastguard Worker %1 = bitcast float* %0 to <4 x float>* 70*9880d681SAndroid Build Coastguard Worker %wide.load = load <4 x float>, <4 x float>* %1, align 4 71*9880d681SAndroid Build Coastguard Worker %2 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %b, <4 x float> %c) 72*9880d681SAndroid Build Coastguard Worker store <4 x float> %2, <4 x float>* %1, align 4 73*9880d681SAndroid Build Coastguard Worker %index.next = add i64 %index, 4 74*9880d681SAndroid Build Coastguard Worker %3 = icmp eq i64 %index.next, 1024 75*9880d681SAndroid Build Coastguard Worker br i1 %3, label %for.end, label %vector.body 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %vector.body 78*9880d681SAndroid Build Coastguard Worker ret void 79*9880d681SAndroid Build Coastguard Worker 80*9880d681SAndroid Build Coastguard Worker; CORE2: Printing analysis 'Cost Model Analysis' for function 'test3': 81*9880d681SAndroid Build Coastguard Worker; CORE2: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %b, <4 x float> %c) 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Worker; COREI7: Printing analysis 'Cost Model Analysis' for function 'test3': 84*9880d681SAndroid Build Coastguard Worker; COREI7: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %wide.load, <4 x float> %b, <4 x float> %c) 85*9880d681SAndroid Build Coastguard Worker 86*9880d681SAndroid Build Coastguard Worker} 87*9880d681SAndroid Build Coastguard Worker 88*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>) nounwind readnone 89