summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-12-23 13:19:18 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-12-23 13:19:18 +0000
commit855ba034089d7ca64c745a9d3847143fe3758667 (patch)
tree535339b0fb3bd638c4fe3d8501f9232f9db4107e /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
parentaa92ea4f121e5c9e2adc6f71aa8d50ebcc400322 (diff)
downloadbcm5719-llvm-855ba034089d7ca64c745a9d3847143fe3758667.tar.gz
bcm5719-llvm-855ba034089d7ca64c745a9d3847143fe3758667.zip
LoopVectorize: For scalars and void types there is no need to compute vector insert/extract costs.
Fixes an assert during the build of oggenc in the test suite. llvm-svn: 171000
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5b1db0b9d14..ddb7f2607e5 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2181,18 +2181,16 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, unsigned VF) {
// elements, times the vector width.
unsigned Cost = 0;
- bool IsVoid = RetTy->isVoidTy();
-
- unsigned InsCost = (IsVoid ? 0 :
- VTTI->getVectorInstrCost(Instruction::InsertElement,
- VectorTy));
-
- unsigned ExtCost = VTTI->getVectorInstrCost(Instruction::ExtractElement,
- VectorTy);
-
- // The cost of inserting the results plus extracting each one of the
- // operands.
- Cost += VF * (InsCost + ExtCost * I->getNumOperands());
+ if (RetTy->isVoidTy() || VF != 1) {
+ unsigned InsCost = VTTI->getVectorInstrCost(Instruction::InsertElement,
+ VectorTy);
+ unsigned ExtCost = VTTI->getVectorInstrCost(Instruction::ExtractElement,
+ VectorTy);
+
+ // The cost of inserting the results plus extracting each one of the
+ // operands.
+ Cost += VF * (InsCost + ExtCost * I->getNumOperands());
+ }
// The cost of executing VF copies of the scalar instruction. This opcode
// is unknown. Assume that it is the same as 'mul'.
OpenPOWER on IntegriCloud