[llvm] r303342 - [X86][AVX512] Add 512-bit vector ctpop costs + tests

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 03:42:35 PDT 2017


Author: rksimon
Date: Thu May 18 05:42:34 2017
New Revision: 303342

URL: http://llvm.org/viewvc/llvm-project?rev=303342&view=rev
Log:
[X86][AVX512] Add 512-bit vector ctpop costs + tests

Modified:
    llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
    llvm/trunk/test/Analysis/CostModel/X86/ctpop.ll

Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=303342&r1=303341&r2=303342&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Thu May 18 05:42:34 2017
@@ -1415,6 +1415,10 @@ int X86TTIImpl::getIntrinsicInstrCost(In
     { ISD::CTLZ,       MVT::v16i32, 22 },
     { ISD::CTLZ,       MVT::v32i16, 18 },
     { ISD::CTLZ,       MVT::v64i8,  17 },
+    { ISD::CTPOP,      MVT::v8i64,   7 },
+    { ISD::CTPOP,      MVT::v16i32, 11 },
+    { ISD::CTPOP,      MVT::v32i16,  9 },
+    { ISD::CTPOP,      MVT::v64i8,   6 },
     { ISD::CTTZ,       MVT::v8i64,  10 },
     { ISD::CTTZ,       MVT::v16i32, 14 },
     { ISD::CTTZ,       MVT::v32i16, 12 },
@@ -1425,6 +1429,8 @@ int X86TTIImpl::getIntrinsicInstrCost(In
     { ISD::BITREVERSE, MVT::v16i32, 24 },
     { ISD::CTLZ,       MVT::v8i64,  29 },
     { ISD::CTLZ,       MVT::v16i32, 35 },
+    { ISD::CTPOP,      MVT::v8i64,  16 },
+    { ISD::CTPOP,      MVT::v16i32, 24 },
     { ISD::CTTZ,       MVT::v8i64,  20 },
     { ISD::CTTZ,       MVT::v16i32, 28 },
   };

Modified: llvm/trunk/test/Analysis/CostModel/X86/ctpop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/ctpop.ll?rev=303342&r1=303341&r2=303342&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/ctpop.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/ctpop.ll Thu May 18 05:42:34 2017
@@ -4,6 +4,8 @@
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=core-avx2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX1 -check-prefix=POPCNT
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver4 -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX -check-prefix=AVX2 -check-prefix=POPCNT
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=knl -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX512 -check-prefix=AVX512F -check-prefix=POPCNT
+; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=skx -cost-model -analyze | FileCheck %s -check-prefix=CHECK -check-prefix=AVX512 -check-prefix=AVX512BW -check-prefix=POPCNT
 
 ; Verify the cost of scalar population count instructions.
 
@@ -56,11 +58,17 @@ declare <8 x i32> @llvm.ctpop.v8i32(<8 x
 declare <16 x i16> @llvm.ctpop.v16i16(<16 x i16>)
 declare <32 x i8> @llvm.ctpop.v32i8(<32 x i8>)
 
+declare <8 x i64> @llvm.ctpop.v8i64(<8 x i64>)
+declare <16 x i32> @llvm.ctpop.v16i32(<16 x i32>)
+declare <32 x i16> @llvm.ctpop.v32i16(<32 x i16>)
+declare <64 x i8> @llvm.ctpop.v64i8(<64 x i8>)
+
 define <2 x i64> @var_ctpop_v2i64(<2 x i64> %a) {
 ; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v2i64':
 ; SSE2: Found an estimated cost of 12 for instruction:   %ctpop
 ; SSE42: Found an estimated cost of 7 for instruction:   %ctpop
 ; AVX: Found an estimated cost of 7 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 7 for instruction:   %ctpop
   %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
   ret <2 x i64> %ctpop
 }
@@ -71,15 +79,29 @@ define <4 x i64> @var_ctpop_v4i64(<4 x i
 ; SSE42: Found an estimated cost of 14 for instruction:   %ctpop
 ; AVX1: Found an estimated cost of 16 for instruction:   %ctpop
 ; AVX2: Found an estimated cost of 7 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 7 for instruction:   %ctpop
   %ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %a)
   ret <4 x i64> %ctpop
 }
 
+define <8 x i64> @var_ctpop_v8i64(<8 x i64> %a) {
+; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i64':
+; SSE2: Found an estimated cost of 48 for instruction:   %ctpop
+; SSE42: Found an estimated cost of 28 for instruction:   %ctpop
+; AVX1: Found an estimated cost of 32 for instruction:   %ctpop
+; AVX2: Found an estimated cost of 14 for instruction:   %ctpop
+; AVX512F: Found an estimated cost of 16 for instruction:   %ctpop
+; AVX512BW: Found an estimated cost of 7 for instruction:   %ctpop
+  %ctpop = call <8 x i64> @llvm.ctpop.v8i64(<8 x i64> %a)
+  ret <8 x i64> %ctpop
+}
+
 define <4 x i32> @var_ctpop_v4i32(<4 x i32> %a) {
 ; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v4i32':
 ; SSE2: Found an estimated cost of 15 for instruction:   %ctpop
 ; SSE42: Found an estimated cost of 11 for instruction:   %ctpop
 ; AVX: Found an estimated cost of 11 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 11 for instruction:   %ctpop
   %ctpop = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
   ret <4 x i32> %ctpop
 }
@@ -90,15 +112,29 @@ define <8 x i32> @var_ctpop_v8i32(<8 x i
 ; SSE42: Found an estimated cost of 22 for instruction:   %ctpop
 ; AVX1: Found an estimated cost of 24 for instruction:   %ctpop
 ; AVX2: Found an estimated cost of 11 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 11 for instruction:   %ctpop
   %ctpop = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %a)
   ret <8 x i32> %ctpop
 }
 
+define <16 x i32> @var_ctpop_v16i32(<16 x i32> %a) {
+; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i32':
+; SSE2: Found an estimated cost of 60 for instruction:   %ctpop
+; SSE42: Found an estimated cost of 44 for instruction:   %ctpop
+; AVX1: Found an estimated cost of 48 for instruction:   %ctpop
+; AVX2: Found an estimated cost of 22 for instruction:   %ctpop
+; AVX512F: Found an estimated cost of 24 for instruction:   %ctpop
+; AVX512BW: Found an estimated cost of 11 for instruction:   %ctpop
+  %ctpop = call <16 x i32> @llvm.ctpop.v16i32(<16 x i32> %a)
+  ret <16 x i32> %ctpop
+}
+
 define <8 x i16> @var_ctpop_v8i16(<8 x i16> %a) {
 ; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v8i16':
 ; SSE2: Found an estimated cost of 13 for instruction:   %ctpop
 ; SSE42: Found an estimated cost of 9 for instruction:   %ctpop
 ; AVX: Found an estimated cost of 9 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 9 for instruction:   %ctpop
   %ctpop = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %a)
   ret <8 x i16> %ctpop
 }
@@ -109,15 +145,29 @@ define <16 x i16> @var_ctpop_v16i16(<16
 ; SSE42: Found an estimated cost of 18 for instruction:   %ctpop
 ; AVX1: Found an estimated cost of 20 for instruction:   %ctpop
 ; AVX2: Found an estimated cost of 9 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 9 for instruction:   %ctpop
   %ctpop = call <16 x i16> @llvm.ctpop.v16i16(<16 x i16> %a)
   ret <16 x i16> %ctpop
 }
 
+define <32 x i16> @var_ctpop_v32i16(<32 x i16> %a) {
+; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v32i16':
+; SSE2: Found an estimated cost of 52 for instruction:   %ctpop
+; SSE42: Found an estimated cost of 36 for instruction:   %ctpop
+; AVX1: Found an estimated cost of 40 for instruction:   %ctpop
+; AVX2: Found an estimated cost of 18 for instruction:   %ctpop
+; AVX512F: Found an estimated cost of 18 for instruction:   %ctpop
+; AVX512BW: Found an estimated cost of 9 for instruction:   %ctpop
+  %ctpop = call <32 x i16> @llvm.ctpop.v32i16(<32 x i16> %a)
+  ret <32 x i16> %ctpop
+}
+
 define <16 x i8> @var_ctpop_v16i8(<16 x i8> %a) {
 ; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v16i8':
 ; SSE2: Found an estimated cost of 10 for instruction:   %ctpop
 ; SSE42: Found an estimated cost of 6 for instruction:   %ctpop
 ; AVX: Found an estimated cost of 6 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 6 for instruction:   %ctpop
   %ctpop = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a)
   ret <16 x i8> %ctpop
 }
@@ -128,6 +178,19 @@ define <32 x i8> @var_ctpop_v32i8(<32 x
 ; SSE42: Found an estimated cost of 12 for instruction:   %ctpop
 ; AVX1: Found an estimated cost of 14 for instruction:   %ctpop
 ; AVX2: Found an estimated cost of 6 for instruction:   %ctpop
+; AVX512: Found an estimated cost of 6 for instruction:   %ctpop
   %ctpop = call <32 x i8> @llvm.ctpop.v32i8(<32 x i8> %a)
   ret <32 x i8> %ctpop
 }
+
+define <64 x i8> @var_ctpop_v64i8(<64 x i8> %a) {
+; CHECK: 'Cost Model Analysis' for function 'var_ctpop_v64i8':
+; SSE2: Found an estimated cost of 40 for instruction:   %ctpop
+; SSE42: Found an estimated cost of 24 for instruction:   %ctpop
+; AVX1: Found an estimated cost of 28 for instruction:   %ctpop
+; AVX2: Found an estimated cost of 12 for instruction:   %ctpop
+; AVX512F: Found an estimated cost of 12 for instruction:   %ctpop
+; AVX512BW: Found an estimated cost of 6 for instruction:   %ctpop
+  %ctpop = call <64 x i8> @llvm.ctpop.v64i8(<64 x i8> %a)
+  ret <64 x i8> %ctpop
+}




More information about the llvm-commits mailing list