summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit13da94734c49c08da03e6d05e5478999b318e220 (patch)
tree65313d3048fd83f87729bd6d194c39823291f9ce /llvm/lib/Analysis/CostModel.cpp
parent6bc6621d73ba631dede6de803c1b8ff08d7f94f1 (diff)
downloadbcm5719-llvm-13da94734c49c08da03e6d05e5478999b318e220.tar.gz
bcm5719-llvm-13da94734c49c08da03e6d05e5478999b318e220.zip
CostModel: add support for Vector Insert and Extract.
llvm-svn: 167329
Diffstat (limited to 'llvm/lib/Analysis/CostModel.cpp')
-rw-r--r--llvm/lib/Analysis/CostModel.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/CostModel.cpp b/llvm/lib/Analysis/CostModel.cpp
index 142d287384d..5adbf458104 100644
--- a/llvm/lib/Analysis/CostModel.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud