From 020be9dc29070407c483e15f65aa2e8624a2beec Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Mon, 5 Nov 2012 21:11:10 +0000 Subject: [PATCH] Cost Model: teach the cost model about expanding integers. llvm-svn: 167401 --- llvm/lib/Target/TargetTransformImpl.cpp | 5 +++-- llvm/test/Analysis/CostModel/X86/i32.ll | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Analysis/CostModel/X86/i32.ll diff --git a/llvm/lib/Target/TargetTransformImpl.cpp b/llvm/lib/Target/TargetTransformImpl.cpp index a9f02ed..4b427a2 100644 --- a/llvm/lib/Target/TargetTransformImpl.cpp +++ b/llvm/lib/Target/TargetTransformImpl.cpp @@ -143,7 +143,8 @@ VectorTargetTransformImpl::getTypeLegalizationCost(LLVMContext &C, if (LK.first == TargetLowering::TypeLegal) return std::make_pair(Cost, Ty.getSimpleVT()); - if (LK.first == TargetLowering::TypeSplitVector) + if (LK.first == TargetLowering::TypeSplitVector || + LK.first == TargetLowering::TypeExpandInteger) Cost *= 2; // Keep legalizing the type. @@ -300,7 +301,7 @@ unsigned VectorTargetTransformImpl::getCmpSelInstrCost(unsigned Opcode, unsigned Cost = getCmpSelInstrCost(Opcode, ValTy->getScalarType(), CondTy); - // return the cost of multiple scalar invocation plus the cost of inserting + // Return the cost of multiple scalar invocation plus the cost of inserting // and extracting the values. return getScalarizationOverhead(ValTy, true, false) + Num * Cost; } diff --git a/llvm/test/Analysis/CostModel/X86/i32.ll b/llvm/test/Analysis/CostModel/X86/i32.ll new file mode 100644 index 0000000..4015e0b --- /dev/null +++ b/llvm/test/Analysis/CostModel/X86/i32.ll @@ -0,0 +1,9 @@ +; RUN: opt < %s -cost-model -analyze -mtriple=i386 -mcpu=corei7-avx | FileCheck %s + + +;CHECK: cost of 2 {{.*}} add +;CHECK: cost of 1 {{.*}} ret +define i32 @no_info(i32 %arg) { + %e = add i64 undef, undef + ret i32 undef +} -- 2.7.4