aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CostModel.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-11-02 22:31:56 +0000
committerNadav Rotem <nrotem@apple.com>2012-11-02 22:31:56 +0000
commitf1495671605b50a4b0386697fee0b76ebae9d17f (patch)
treebde0209eb4040e18f115562308ccc14b695ef552 /lib/Analysis/CostModel.cpp
parent4c8edb41e5b9697d9a6bfa5761dbba9430626365 (diff)
CostModel: add support for Vector Insert and Extract.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CostModel.cpp')
-rw-r--r--lib/Analysis/CostModel.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp
index 142d287384..5adbf45810 100644
--- a/lib/Analysis/CostModel.cpp
+++ b/lib/Analysis/CostModel.cpp
@@ -150,6 +150,24 @@ unsigned CostModelAnalysis::getInstructionCost(Instruction *I) const {
Type *SrcTy = I->getOperand(0)->getType();
return VTTI->getCastInstrCost(I->getOpcode(), I->getType(), SrcTy);
}
+ case Instruction::ExtractElement: {
+ ExtractElementInst * EEI = cast<ExtractElementInst>(I);
+ ConstantInt *CI = dyn_cast<ConstantInt>(I->getOperand(1));
+ unsigned Idx = -1;
+ if (CI)
+ Idx = CI->getZExtValue();
+ return VTTI->getVectorInstrCost(I->getOpcode(),
+ EEI->getOperand(0)->getType(), Idx);
+ }
+ case Instruction::InsertElement: {
+ InsertElementInst * IE = cast<InsertElementInst>(I);
+ ConstantInt *CI = dyn_cast<ConstantInt>(IE->getOperand(2));
+ unsigned Idx = -1;
+ if (CI)
+ Idx = CI->getZExtValue();
+ return VTTI->getVectorInstrCost(I->getOpcode(),
+ IE->getType(), Idx);
+ }
default:
// We don't have any information on this instruction.
return -1;