X86 cost model: Exit before calling getSimpleVT on non-simple VTs
authorArnold Schwaighofer <aschwaighofer@apple.com>
Wed, 17 Apr 2013 20:04:53 +0000 (20:04 +0000)
committerArnold Schwaighofer <aschwaighofer@apple.com>
Wed, 17 Apr 2013 20:04:53 +0000 (20:04 +0000)
getSimpleVT can only handle simple value types.

radar://13676022

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

lib/Target/X86/X86TargetTransformInfo.cpp
test/Analysis/CostModel/X86/uitofp.ll

index 488c2a42b2d41a816cd9ed9b012b03402f4d37c5..eba9d782d5c35a5a5fec723b31ed0d80e38b54aa 100644 (file)
@@ -371,6 +371,10 @@ unsigned X86TTI::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) const {
   EVT SrcTy = TLI->getValueType(Src);
   EVT DstTy = TLI->getValueType(Dst);
 
   EVT SrcTy = TLI->getValueType(Src);
   EVT DstTy = TLI->getValueType(Dst);
 
+  // The function getSimpleVT only handles simple value types.
+  if (!SrcTy.isSimple() || !DstTy.isSimple())
+    return TargetTransformInfo::getCastInstrCost(Opcode, Dst, Src);
+
   static const TypeConversionCostTblEntry<MVT> AVXConversionTbl[] = {
     { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
     { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
   static const TypeConversionCostTblEntry<MVT> AVXConversionTbl[] = {
     { ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
     { ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
index aed3f2a67bf9907bdbc7f781ef6c1fa4668f39a0..a41a04df84eca64065e5aca27fa763f0e2e94a24 100644 (file)
@@ -1,6 +1,11 @@
 ; RUN: llc -mtriple=x86_64-apple-darwin -mcpu=core2 < %s | FileCheck --check-prefix=SSE2-CODEGEN %s
 ; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck --check-prefix=SSE2 %s
 
 ; RUN: llc -mtriple=x86_64-apple-darwin -mcpu=core2 < %s | FileCheck --check-prefix=SSE2-CODEGEN %s
 ; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck --check-prefix=SSE2 %s
 
+; In X86TargetTransformInfo::getCastInstrCost we have code that depends on
+; getSimpleVT on a value type. On AVX2 we execute this code. Make sure we exit
+; early if the type is not a simple value type before we call this function.
+; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core-avx2 -cost-model -analyze < %s
+
 define <2 x double> @uitofpv2i8v2double(<2 x i8> %a) {
   ; SSE2: uitofpv2i8v2double
   ; SSE2: cost of 20 {{.*}} uitofp
 define <2 x double> @uitofpv2i8v2double(<2 x i8> %a) {
   ; SSE2: uitofpv2i8v2double
   ; SSE2: cost of 20 {{.*}} uitofp
@@ -360,3 +365,4 @@ define <32 x float> @uitofpv32i64v32float(<32 x i64> %a) {
   %1 = uitofp <32 x i64> %a to <32 x float>
   ret <32 x float> %1
 }
   %1 = uitofp <32 x i64> %a to <32 x float>
   ret <32 x float> %1
 }
+