diff options
author | Yi Jiang <yjiang@apple.com> | 2013-09-19 17:48:48 +0000 |
---|---|---|
committer | Yi Jiang <yjiang@apple.com> | 2013-09-19 17:48:48 +0000 |
commit | cdfb43f0a68274f40340af73218699265466c074 (patch) | |
tree | 5a9270302f7e75020b7feb135ae1b1c2a8850501 /test/Analysis | |
parent | e56a4d9236336910cf46976c22dc767ebc8ced43 (diff) | |
download | external_llvm-cdfb43f0a68274f40340af73218699265466c074.zip external_llvm-cdfb43f0a68274f40340af73218699265466c074.tar.gz external_llvm-cdfb43f0a68274f40340af73218699265466c074.tar.bz2 |
X86 horizontal vector reduction cost model
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/CostModel/X86/reduction.ll | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/test/Analysis/CostModel/X86/reduction.ll b/test/Analysis/CostModel/X86/reduction.ll index 37d5f24..78e65ae 100644 --- a/test/Analysis/CostModel/X86/reduction.ll +++ b/test/Analysis/CostModel/X86/reduction.ll @@ -1,4 +1,7 @@ ; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=core2 -mtriple=x86_64-apple-darwin | FileCheck %s +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=corei7 -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=SSE3 +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=corei7-avx -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=AVX +; RUN: opt < %s -cost-model -costmodel-reduxcost=true -analyze -mcpu=core-avx2 -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=AVX2 define fastcc float @reduction_cost_float(<4 x float> %rdx) { %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> @@ -55,6 +58,7 @@ define fastcc float @pairwise_hadd(<4 x float> %rdx, float %f1) { %r2 = fadd float %r, %f1 ret float %r2 } + define fastcc float @pairwise_hadd_assoc(<4 x float> %rdx, float %f1) { %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 0, i32 2 , i32 undef, i32 undef> @@ -92,3 +96,270 @@ define fastcc float @pairwise_hadd_skip_first(<4 x float> %rdx, float %f1) { %r2 = fadd float %r, %f1 ret float %r2 } + +define fastcc double @no_pairwise_reduction2double(<2 x double> %rdx, double %f1) { + %rdx.shuf = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx = fadd <2 x double> %rdx, %rdx.shuf + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 2 {{.*}} extractelement +; AVX2: cost of 2 {{.*}} extractelement + + %r = extractelement <2 x double> %bin.rdx, i32 0 + ret double %r +} + +define fastcc float @no_pairwise_reduction4float(<4 x float> %rdx, float %f1) { + %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc double @no_pairwise_reduction4double(<4 x double> %rdx, double %f1) { + %rdx.shuf = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x double> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x double> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @no_pairwise_reduction8float(<8 x float> %rdx, float %f1) { + %rdx.shuf3 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = fadd <8 x float> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x float> %bin.rdx4, <8 x float> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = fadd <8 x float> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x float> %bin.rdx, <8 x float> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <8 x float> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <8 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc i64 @no_pairwise_reduction2i64(<2 x i64> %rdx, i64 %f1) { + %rdx.shuf = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx = add <2 x i64> %rdx, %rdx.shuf + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 1 {{.*}} extractelement +; AVX2: cost of 1 {{.*}} extractelement + + %r = extractelement <2 x i64> %bin.rdx, i32 0 + ret i64 %r +} + +define fastcc i32 @no_pairwise_reduction4i32(<4 x i32> %rdx, i32 %f1) { + %rdx.shuf = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i32> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i32> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 3 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc i64 @no_pairwise_reduction4i64(<4 x i64> %rdx, i64 %f1) { + %rdx.shuf = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i64> %rdx, %rdx.shuf + %rdx.shuf7 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i64> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i16 @no_pairwise_reduction8i16(<8 x i16> %rdx, i16 %f1) { + %rdx.shuf3 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = add <8 x i16> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x i16> %bin.rdx4, <8 x i16> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i16> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i16> %bin.rdx, %rdx.shuf7 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <8 x i16> %bin.rdx8, i32 0 + ret i16 %r +} + +define fastcc i32 @no_pairwise_reduction8i32(<8 x i32> %rdx, i32 %f1) { + %rdx.shuf3 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx4 = add <8 x i32> %rdx, %rdx.shuf3 + %rdx.shuf = shufflevector <8 x i32> %bin.rdx4, <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i32> %bin.rdx4, %rdx.shuf + %rdx.shuf7 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i32> %bin.rdx, %rdx.shuf7 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc double @pairwise_reduction2double(<2 x double> %rdx, double %f1) { + %rdx.shuf.1.0 = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 0, i32 undef> + %rdx.shuf.1.1 = shufflevector <2 x double> %rdx, <2 x double> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx8 = fadd <2 x double> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 2 {{.*}} extractelement +; AVX2: cost of 2 {{.*}} extractelement + + %r = extractelement <2 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @pairwise_reduction4float(<4 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 4 {{.*}} extractelement +; AVX: cost of 4 {{.*}} extractelement +; AVX2: cost of 4 {{.*}} extractelement + + %r = extractelement <4 x float> %bin.rdx8, i32 0 + ret float %r +} + +define fastcc double @pairwise_reduction4double(<4 x double> %rdx, double %f1) { + %rdx.shuf.0.0 = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x double> %rdx, <4 x double> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = fadd <4 x double> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x double> %bin.rdx, <4 x double> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <4 x double> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <4 x double> %bin.rdx8, i32 0 + ret double %r +} + +define fastcc float @pairwise_reduction8float(<8 x float> %rdx, float %f1) { + %rdx.shuf.0.0 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x float> %rdx, <8 x float> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = fadd <8 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x float> %bin.rdx, <8 x float> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x float> %bin.rdx, <8 x float> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = fadd <8 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x float> %bin.rdx8, <8 x float> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x float> %bin.rdx8, <8 x float> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = fadd <8 x float> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; AVX: cost of 7 {{.*}} extractelement +; AVX2: cost of 7 {{.*}} extractelement + + %r = extractelement <8 x float> %bin.rdx9, i32 0 + ret float %r +} + +define fastcc i64 @pairwise_reduction2i64(<2 x i64> %rdx, i64 %f1) { + %rdx.shuf.1.0 = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 0, i32 undef> + %rdx.shuf.1.1 = shufflevector <2 x i64> %rdx, <2 x i64> undef, <2 x i32> <i32 1, i32 undef> + %bin.rdx8 = add <2 x i64> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 2 {{.*}} extractelement +; AVX: cost of 1 {{.*}} extractelement +; AVX2: cost of 1 {{.*}} extractelement + + %r = extractelement <2 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i32 @pairwise_reduction4i32(<4 x i32> %rdx, i32 %f1) { + %rdx.shuf.0.0 = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x i32> %rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i32> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x i32> %bin.rdx, <4 x i32> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i32> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; SSE3: cost of 3 {{.*}} extractelement +; AVX: cost of 3 {{.*}} extractelement +; AVX2: cost of 3 {{.*}} extractelement + + %r = extractelement <4 x i32> %bin.rdx8, i32 0 + ret i32 %r +} + +define fastcc i64 @pairwise_reduction4i64(<4 x i64> %rdx, i64 %f1) { + %rdx.shuf.0.0 = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 0, i32 2, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <4 x i64> %rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 3, i32 undef, i32 undef> + %bin.rdx = add <4 x i64> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <4 x i64> %bin.rdx, <4 x i64> undef, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <4 x i64> %rdx.shuf.1.0, %rdx.shuf.1.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <4 x i64> %bin.rdx8, i32 0 + ret i64 %r +} + +define fastcc i16 @pairwise_reduction8i16(<8 x i16> %rdx, i16 %f1) { + %rdx.shuf.0.0 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x i16> %rdx, <8 x i16> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i16> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x i16> %bin.rdx, <8 x i16> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i16> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x i16> %bin.rdx8, <8 x i16> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x i16> %bin.rdx8, <8 x i16> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = add <8 x i16> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; SSE3: cost of 5 {{.*}} extractelement +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i16> %bin.rdx9, i32 0 + ret i16 %r +} + +define fastcc i32 @pairwise_reduction8i32(<8 x i32> %rdx, i32 %f1) { + %rdx.shuf.0.0 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 0, i32 2, i32 4, i32 6,i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.0.1 = shufflevector <8 x i32> %rdx, <8 x i32> undef, <8 x i32> <i32 1, i32 3, i32 5, i32 7,i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx = add <8 x i32> %rdx.shuf.0.0, %rdx.shuf.0.1 + %rdx.shuf.1.0 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef,<8 x i32> <i32 0, i32 2, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.1.1 = shufflevector <8 x i32> %bin.rdx, <8 x i32> undef,<8 x i32> <i32 1, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx8 = add <8 x i32> %rdx.shuf.1.0, %rdx.shuf.1.1 + %rdx.shuf.2.0 = shufflevector <8 x i32> %bin.rdx8, <8 x i32> undef,<8 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %rdx.shuf.2.1 = shufflevector <8 x i32> %bin.rdx8, <8 x i32> undef,<8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> + %bin.rdx9 = add <8 x i32> %rdx.shuf.2.0, %rdx.shuf.2.1 + +; AVX: cost of 5 {{.*}} extractelement +; AVX2: cost of 5 {{.*}} extractelement + + %r = extractelement <8 x i32> %bin.rdx9, i32 0 + ret i32 %r +} |