Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 9c63f0d

Browse files
committed
X86 cost model: Exit before calling getSimpleVT on non-simple VTs
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
1 parent d58b50b commit 9c63f0d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ unsigned X86TTI::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) const {
371371
EVT SrcTy = TLI->getValueType(Src);
372372
EVT DstTy = TLI->getValueType(Dst);
373373

374+
// The function getSimpleVT only handles simple value types.
375+
if (!SrcTy.isSimple() || !DstTy.isSimple())
376+
return TargetTransformInfo::getCastInstrCost(Opcode, Dst, Src);
377+
374378
static const TypeConversionCostTblEntry<MVT> AVXConversionTbl[] = {
375379
{ ISD::SIGN_EXTEND, MVT::v8i32, MVT::v8i16, 1 },
376380
{ ISD::ZERO_EXTEND, MVT::v8i32, MVT::v8i16, 1 },

test/Analysis/CostModel/X86/uitofp.ll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
; RUN: llc -mtriple=x86_64-apple-darwin -mcpu=core2 < %s | FileCheck --check-prefix=SSE2-CODEGEN %s
22
; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core2 -cost-model -analyze < %s | FileCheck --check-prefix=SSE2 %s
33

4+
; In X86TargetTransformInfo::getCastInstrCost we have code that depends on
5+
; getSimpleVT on a value type. On AVX2 we execute this code. Make sure we exit
6+
; early if the type is not a simple value type before we call this function.
7+
; RUN: opt -mtriple=x86_64-apple-darwin -mcpu=core-avx2 -cost-model -analyze < %s
8+
49
define <2 x double> @uitofpv2i8v2double(<2 x i8> %a) {
510
; SSE2: uitofpv2i8v2double
611
; SSE2: cost of 20 {{.*}} uitofp
@@ -360,3 +365,4 @@ define <32 x float> @uitofpv32i64v32float(<32 x i64> %a) {
360365
%1 = uitofp <32 x i64> %a to <32 x float>
361366
ret <32 x float> %1
362367
}
368+

0 commit comments

Comments
 (0)