[llvm] r303022 - [X86][AVX2] Fix costs for v4i64 ashr by splat

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun May 14 13:25:42 PDT 2017


Author: rksimon
Date: Sun May 14 15:25:42 2017
New Revision: 303022

URL: http://llvm.org/viewvc/llvm-project?rev=303022&view=rev
Log:
[X86][AVX2] Fix costs for v4i64 ashr by splat

Modified:
    llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
    llvm/trunk/test/Analysis/CostModel/X86/vshift-ashr-cost.ll

Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=303022&r1=303021&r2=303022&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Sun May 14 15:25:42 2017
@@ -471,6 +471,11 @@ int X86TTIImpl::getArithmeticInstrCost(
   if (ST->hasSSE2() &&
       ((Op2Info == TargetTransformInfo::OK_UniformConstantValue) ||
        (Op2Info == TargetTransformInfo::OK_UniformValue))) {
+
+    // Handle AVX2 uniform v4i64 ISD::SRA, it's not worth a table.
+    if (ISD == ISD::SRA && LT.second == MVT::v4i64 && ST->hasAVX2())
+      return LT.first * 4; // 2*psrad + shuffle.
+
     if (const auto *Entry =
             CostTableLookup(SSE2UniformShiftCostTable, ISD, LT.second))
       return LT.first * Entry->Cost;

Modified: llvm/trunk/test/Analysis/CostModel/X86/vshift-ashr-cost.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/vshift-ashr-cost.ll?rev=303022&r1=303021&r2=303022&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/vshift-ashr-cost.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/vshift-ashr-cost.ll Sun May 14 15:25:42 2017
@@ -192,7 +192,7 @@ define <4 x i64> @splatvar_shift_v4i64(<
 ; SSE2: Found an estimated cost of 8 for instruction:   %shift
 ; SSE41: Found an estimated cost of 8 for instruction:   %shift
 ; AVX: Found an estimated cost of 10 for instruction:   %shift
-; AVX2: Found an estimated cost of 10 for instruction:   %shift
+; AVX2: Found an estimated cost of 4 for instruction:   %shift
 ; AVX512: Found an estimated cost of 1 for instruction:   %shift
 ; XOP: Found an estimated cost of 6 for instruction:   %shift
   %insert = insertelement <4 x i64> undef, i64 %b, i32 0
@@ -206,7 +206,7 @@ define <8 x i64> @splatvar_shift_v8i64(<
 ; SSE2: Found an estimated cost of 16 for instruction:   %shift
 ; SSE41: Found an estimated cost of 16 for instruction:   %shift
 ; AVX: Found an estimated cost of 20 for instruction:   %shift
-; AVX2: Found an estimated cost of 20 for instruction:   %shift
+; AVX2: Found an estimated cost of 8 for instruction:   %shift
 ; AVX512: Found an estimated cost of 1 for instruction:   %shift
 ; XOP: Found an estimated cost of 12 for instruction:   %shift
   %insert = insertelement <8 x i64> undef, i64 %b, i32 0




More information about the llvm-commits mailing list