[llvm] r329498 - [CostModel][X86] Fix v32i16/v64i8 SETCC costs on AVX512BW targets

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 7 06:24:33 PDT 2018


Author: rksimon
Date: Sat Apr  7 06:24:33 2018
New Revision: 329498

URL: http://llvm.org/viewvc/llvm-project?rev=329498&view=rev
Log:
[CostModel][X86] Fix v32i16/v64i8 SETCC costs on AVX512BW targets

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

Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=329498&r1=329497&r2=329498&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Sat Apr  7 06:24:33 2018
@@ -1534,6 +1534,15 @@ int X86TTIImpl::getCmpSelInstrCost(unsig
     { ISD::SETCC,   MVT::v16f32,  1 },
   };
 
+  static const CostTblEntry AVX512BWCostTbl[] = {
+    { ISD::SETCC,   MVT::v32i16,  1 },
+    { ISD::SETCC,   MVT::v64i8,   1 },
+  };
+
+  if (ST->hasBWI())
+    if (const auto *Entry = CostTableLookup(AVX512BWCostTbl, ISD, MTy))
+      return LT.first * Entry->Cost;
+
   if (ST->hasAVX512())
     if (const auto *Entry = CostTableLookup(AVX512CostTbl, ISD, MTy))
       return LT.first * Entry->Cost;

Modified: llvm/trunk/test/Analysis/CostModel/X86/cmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/cmp.ll?rev=329498&r1=329497&r2=329498&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/cmp.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/cmp.ll Sat Apr  7 06:24:33 2018
@@ -256,12 +256,12 @@ define i32 @cmp_int(i32 %arg) {
 ; AVX512BW-LABEL: 'cmp_int'
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V16I8 = icmp eq <16 x i8> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V32I8 = icmp eq <32 x i8> undef, undef
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V64I8 = icmp eq <64 x i8> undef, undef
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 256 for instruction: %V128I8 = icmp eq <128 x i8> undef, undef
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V64I8 = icmp eq <64 x i8> undef, undef
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V128I8 = icmp eq <128 x i8> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V8I16 = icmp eq <8 x i16> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V16I16 = icmp eq <16 x i16> undef, undef
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 64 for instruction: %V32I16 = icmp eq <32 x i16> undef, undef
-; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 128 for instruction: %V64I16 = icmp eq <64 x i16> undef, undef
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V32I16 = icmp eq <32 x i16> undef, undef
+; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %V64I16 = icmp eq <64 x i16> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V4I32 = icmp eq <4 x i32> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V8I32 = icmp eq <8 x i32> undef, undef
 ; AVX512BW-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %V16I32 = icmp eq <16 x i32> undef, undef




More information about the llvm-commits mailing list