From 4630834e7c0e4ee783c6068f3b67651a5ef50e08 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 21 Aug 2016 19:06:25 +0000 Subject: [PATCH] [CostModel][X86] Added fsqrt and fma costs git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279403 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Analysis/CostModel/X86/arith-fp.ll | 106 +++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 2 deletions(-) diff --git a/test/Analysis/CostModel/X86/arith-fp.ll b/test/Analysis/CostModel/X86/arith-fp.ll index 371746a5e16..6a68a7f330f 100644 --- a/test/Analysis/CostModel/X86/arith-fp.ll +++ b/test/Analysis/CostModel/X86/arith-fp.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+ssse3 | FileCheck %s --check-prefix=CHECK --check-prefix=SSSE3 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+sse4.2 | FileCheck %s --check-prefix=CHECK --check-prefix=SSE42 -; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx | FileCheck %s --check-prefix=CHECK --check-prefix=AVX -; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx2 | FileCheck %s --check-prefix=CHECK --check-prefix=AVX2 +; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx,+fma | FileCheck %s --check-prefix=CHECK --check-prefix=AVX +; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx2,+fma | FileCheck %s --check-prefix=CHECK --check-prefix=AVX2 ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx512f | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512 --check-prefix=AVX512F ; RUN: opt < %s -cost-model -analyze -mtriple=x86_64-apple-macosx10.8.0 -mattr=+avx512f,+avx512bw | FileCheck %s --check-prefix=CHECK --check-prefix=AVX512 --check-prefix=AVX512BW @@ -222,3 +222,105 @@ define i32 @frem(i32 %arg) { ret i32 undef } + +; CHECK-LABEL: 'fsqrt' +define i32 @fsqrt(i32 %arg) { + ; SSSE3: cost of 1 {{.*}} %A = call <4 x float> @llvm.sqrt.v4f32 + ; SSE42: cost of 1 {{.*}} %A = call <4 x float> @llvm.sqrt.v4f32 + ; AVX: cost of 1 {{.*}} %A = call <4 x float> @llvm.sqrt.v4f32 + ; AVX2: cost of 1 {{.*}} %A = call <4 x float> @llvm.sqrt.v4f32 + ; AVX512: cost of 1 {{.*}} %A = call <4 x float> @llvm.sqrt.v4f32 + %A = call <4 x float> @llvm.sqrt.v4f32(<4 x float> undef) + ; SSSE3: cost of 4 {{.*}} %B = call <8 x float> @llvm.sqrt.v8f32 + ; SSE42: cost of 4 {{.*}} %B = call <8 x float> @llvm.sqrt.v8f32 + ; AVX: cost of 1 {{.*}} %B = call <8 x float> @llvm.sqrt.v8f32 + ; AVX2: cost of 1 {{.*}} %B = call <8 x float> @llvm.sqrt.v8f32 + ; AVX512: cost of 1 {{.*}} %B = call <8 x float> @llvm.sqrt.v8f32 + %B = call <8 x float> @llvm.sqrt.v8f32(<8 x float> undef) + ; SSSE3: cost of 8 {{.*}} %C = call <16 x float> @llvm.sqrt.v16f32 + ; SSE42: cost of 8 {{.*}} %C = call <16 x float> @llvm.sqrt.v16f32 + ; AVX: cost of 4 {{.*}} %C = call <16 x float> @llvm.sqrt.v16f32 + ; AVX2: cost of 4 {{.*}} %C = call <16 x float> @llvm.sqrt.v16f32 + ; AVX512: cost of 1 {{.*}} %C = call <16 x float> @llvm.sqrt.v16f32 + %C = call <16 x float> @llvm.sqrt.v16f32(<16 x float> undef) + + ; SSSE3: cost of 1 {{.*}} %D = call <2 x double> @llvm.sqrt.v2f64 + ; SSE42: cost of 1 {{.*}} %D = call <2 x double> @llvm.sqrt.v2f64 + ; AVX: cost of 1 {{.*}} %D = call <2 x double> @llvm.sqrt.v2f64 + ; AVX2: cost of 1 {{.*}} %D = call <2 x double> @llvm.sqrt.v2f64 + ; AVX512: cost of 1 {{.*}} %D = call <2 x double> @llvm.sqrt.v2f64 + %D = call <2 x double> @llvm.sqrt.v2f64(<2 x double> undef) + ; SSSE3: cost of 4 {{.*}} %E = call <4 x double> @llvm.sqrt.v4f64 + ; SSE42: cost of 4 {{.*}} %E = call <4 x double> @llvm.sqrt.v4f64 + ; AVX: cost of 1 {{.*}} %E = call <4 x double> @llvm.sqrt.v4f64 + ; AVX2: cost of 1 {{.*}} %E = call <4 x double> @llvm.sqrt.v4f64 + ; AVX512: cost of 1 {{.*}} %E = call <4 x double> @llvm.sqrt.v4f64 + %E = call <4 x double> @llvm.sqrt.v4f64(<4 x double> undef) + ; SSSE3: cost of 8 {{.*}} %F = call <8 x double> @llvm.sqrt.v8f64 + ; SSE42: cost of 8 {{.*}} %F = call <8 x double> @llvm.sqrt.v8f64 + ; AVX: cost of 4 {{.*}} %F = call <8 x double> @llvm.sqrt.v8f64 + ; AVX2: cost of 4 {{.*}} %F = call <8 x double> @llvm.sqrt.v8f64 + ; AVX512: cost of 1 {{.*}} %F = call <8 x double> @llvm.sqrt.v8f64 + %F = call <8 x double> @llvm.sqrt.v8f64(<8 x double> undef) + + ret i32 undef +} + +; CHECK-LABEL: 'fma' +define i32 @fma(i32 %arg) { + ; SSSE3: cost of 52 {{.*}} %A = call <4 x float> @llvm.fma.v4f32 + ; SSE42: cost of 52 {{.*}} %A = call <4 x float> @llvm.fma.v4f32 + ; AVX: cost of 1 {{.*}} %A = call <4 x float> @llvm.fma.v4f32 + ; AVX2: cost of 1 {{.*}} %A = call <4 x float> @llvm.fma.v4f32 + ; AVX512: cost of 1 {{.*}} %A = call <4 x float> @llvm.fma.v4f32 + %A = call <4 x float> @llvm.fma.v4f32(<4 x float> undef, <4 x float> undef, <4 x float> undef) + ; SSSE3: cost of 104 {{.*}} %B = call <8 x float> @llvm.fma.v8f32 + ; SSE42: cost of 104 {{.*}} %B = call <8 x float> @llvm.fma.v8f32 + ; AVX: cost of 1 {{.*}} %B = call <8 x float> @llvm.fma.v8f32 + ; AVX2: cost of 1 {{.*}} %B = call <8 x float> @llvm.fma.v8f32 + ; AVX512: cost of 1 {{.*}} %B = call <8 x float> @llvm.fma.v8f32 + %B = call <8 x float> @llvm.fma.v8f32(<8 x float> undef, <8 x float> undef, <8 x float> undef) + ; SSSE3: cost of 208 {{.*}} %C = call <16 x float> @llvm.fma.v16f32 + ; SSE42: cost of 208 {{.*}} %C = call <16 x float> @llvm.fma.v16f32 + ; AVX: cost of 4 {{.*}} %C = call <16 x float> @llvm.fma.v16f32 + ; AVX2: cost of 4 {{.*}} %C = call <16 x float> @llvm.fma.v16f32 + ; AVX512: cost of 1 {{.*}} %C = call <16 x float> @llvm.fma.v16f32 + %C = call <16 x float> @llvm.fma.v16f32(<16 x float> undef, <16 x float> undef, <16 x float> undef) + + ; SSSE3: cost of 24 {{.*}} %D = call <2 x double> @llvm.fma.v2f64 + ; SSE42: cost of 24 {{.*}} %D = call <2 x double> @llvm.fma.v2f64 + ; AVX: cost of 1 {{.*}} %D = call <2 x double> @llvm.fma.v2f64 + ; AVX2: cost of 1 {{.*}} %D = call <2 x double> @llvm.fma.v2f64 + ; AVX512: cost of 1 {{.*}} %D = call <2 x double> @llvm.fma.v2f64 + %D = call <2 x double> @llvm.fma.v2f64(<2 x double> undef, <2 x double> undef, <2 x double> undef) + ; SSSE3: cost of 48 {{.*}} %E = call <4 x double> @llvm.fma.v4f64 + ; SSE42: cost of 48 {{.*}} %E = call <4 x double> @llvm.fma.v4f64 + ; AVX: cost of 1 {{.*}} %E = call <4 x double> @llvm.fma.v4f64 + ; AVX2: cost of 1 {{.*}} %E = call <4 x double> @llvm.fma.v4f64 + ; AVX512: cost of 1 {{.*}} %E = call <4 x double> @llvm.fma.v4f64 + %E = call <4 x double> @llvm.fma.v4f64(<4 x double> undef, <4 x double> undef, <4 x double> undef) + ; SSSE3: cost of 96 {{.*}} %F = call <8 x double> @llvm.fma.v8f64 + ; SSE42: cost of 96 {{.*}} %F = call <8 x double> @llvm.fma.v8f64 + ; AVX: cost of 4 {{.*}} %F = call <8 x double> @llvm.fma.v8f64 + ; AVX2: cost of 4 {{.*}} %F = call <8 x double> @llvm.fma.v8f64 + ; AVX512: cost of 1 {{.*}} %F = call <8 x double> @llvm.fma.v8f64 + %F = call <8 x double> @llvm.fma.v8f64(<8 x double> undef, <8 x double> undef, <8 x double> undef) + + ret i32 undef +} + +declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) +declare <8 x float> @llvm.sqrt.v8f32(<8 x float>) +declare <16 x float> @llvm.sqrt.v16f32(<16 x float>) + +declare <2 x double> @llvm.sqrt.v2f64(<2 x double>) +declare <4 x double> @llvm.sqrt.v4f64(<4 x double>) +declare <8 x double> @llvm.sqrt.v8f64(<8 x double>) + +declare <4 x float> @llvm.fma.v4f32(<4 x float>, <4 x float>, <4 x float>) +declare <8 x float> @llvm.fma.v8f32(<8 x float>, <8 x float>, <8 x float>) +declare <16 x float> @llvm.fma.v16f32(<16 x float>, <16 x float>, <16 x float>) + +declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) +declare <4 x double> @llvm.fma.v4f64(<4 x double>, <4 x double>, <4 x double>) +declare <8 x double> @llvm.fma.v8f64(<8 x double>, <8 x double>, <8 x double>) -- 2.11.0