[llvm] r207371 - X86TTI: Adjust sdiv cost now that we can lower it on plain SSE2.

Benjamin Kramer benny.kra at googlemail.com
Sun Apr 27 11:47:55 PDT 2014


Author: d0k
Date: Sun Apr 27 13:47:54 2014
New Revision: 207371

URL: http://llvm.org/viewvc/llvm-project?rev=207371&view=rev
Log:
X86TTI: Adjust sdiv cost now that we can lower it on plain SSE2.

Includes a fix for a horrible typo that caused all SDIV costs to be
slightly off :)

Modified:
    llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp
    llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
    llvm/trunk/test/Analysis/CostModel/X86/vdiv-cost.ll

Modified: llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp?rev=207371&r1=207370&r2=207371&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringBase.cpp Sun Apr 27 13:47:54 2014
@@ -1327,7 +1327,7 @@ int TargetLoweringBase::InstructionOpcod
   case Mul:            return ISD::MUL;
   case FMul:           return ISD::FMUL;
   case UDiv:           return ISD::UDIV;
-  case SDiv:           return ISD::UDIV;
+  case SDiv:           return ISD::SDIV;
   case FDiv:           return ISD::FDIV;
   case URem:           return ISD::UREM;
   case SRem:           return ISD::SREM;

Modified: llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp?rev=207371&r1=207370&r2=207371&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetTransformInfo.cpp Sun Apr 27 13:47:54 2014
@@ -369,11 +369,16 @@ unsigned X86TTI::getArithmeticInstrCost(
 
     { ISD::SDIV, MVT::v8i16,  6 }, // pmulhw sequence
     { ISD::UDIV, MVT::v8i16,  6 }, // pmulhuw sequence
+    { ISD::SDIV, MVT::v4i32, 19 }, // pmuludq sequence
     { ISD::UDIV, MVT::v4i32, 15 }, // pmuludq sequence
   };
 
   if (Op2Info == TargetTransformInfo::OK_UniformConstantValue &&
       ST->hasSSE2()) {
+    // pmuldq sequence.
+    if (ISD == ISD::SDIV && LT.second == MVT::v4i32 && ST->hasSSE41())
+      return LT.first * 15;
+
     int Idx = CostTableLookup(SSE2UniformConstCostTable, ISD, LT.second);
     if (Idx != -1)
       return LT.first * SSE2UniformConstCostTable[Idx].Cost;

Modified: llvm/trunk/test/Analysis/CostModel/X86/vdiv-cost.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/vdiv-cost.ll?rev=207371&r1=207370&r2=207371&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/vdiv-cost.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/vdiv-cost.ll Sun Apr 27 13:47:54 2014
@@ -69,7 +69,7 @@ define <4 x i32> @test8(<4 x i32> %a) {
   ret <4 x i32> %div
 
 ; CHECK: 'Cost Model Analysis' for function 'test8':
-; SSE2: Found an estimated cost of 15 for instruction:   %div
+; SSE2: Found an estimated cost of 19 for instruction:   %div
 ; AVX2: Found an estimated cost of 15 for instruction:   %div
 }
 
@@ -78,7 +78,7 @@ define <8 x i32> @test9(<8 x i32> %a) {
   ret <8 x i32> %div
 
 ; CHECK: 'Cost Model Analysis' for function 'test9':
-; SSE2: Found an estimated cost of 30 for instruction:   %div
+; SSE2: Found an estimated cost of 38 for instruction:   %div
 ; AVX2: Found an estimated cost of 15 for instruction:   %div
 }
 





More information about the llvm-commits mailing list