X86TTI: Adjust sdiv cost now that we can lower it on plain SSE2.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 27 Apr 2014 18:47:54 +0000 (18:47 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 27 Apr 2014 18:47:54 +0000 (18:47 +0000)
Includes a fix for a horrible typo that caused all SDIV costs to be
slightly off :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207371 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 47ee2b0988f494f6ecd03bace666b60abb3ad043..978432411ef877ca5b1134a16e0245f199608213 100644 (file)
@@ -1327,7 +1327,7 @@ int TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode) const {
   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;
index 628e9130a151e69d308dcb4d8e58f1a239b72ee3..1543f109b4cb486c24f1ae032540751ec4375770 100644 (file)
@@ -369,11 +369,16 @@ unsigned X86TTI::getArithmeticInstrCost(unsigned Opcode, Type *Ty,
 
     { 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;
index 4ba1ef07ad7f8a33bd66049608a8371ed383c85d..c8e4557cbefdc61bea6620385fb01de6d7a530e7 100644 (file)
@@ -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
 }