diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2017-01-30 05:38:05 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2017-01-30 05:38:05 +0000 |
commit | 3f71d6a38e7eabff47fa7900bd609b0fa64b1670 (patch) | |
tree | 63d4865b9d2134caf2c35e04acf43286adf1ac10 /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | 0265a3947280915c55cd6224c42447d924639405 (diff) | |
download | bcm5719-llvm-3f71d6a38e7eabff47fa7900bd609b0fa64b1670.tar.gz bcm5719-llvm-3f71d6a38e7eabff47fa7900bd609b0fa64b1670.zip |
[LoopVectorize] Improve getVectorCallCost() getScalarizationOverhead() call.
By calling getScalarizationOverhead with the CallInst instead of the types of
its arguments, we make sure that only unique call arguments are added to the
scalarization cost.
getScalarizationOverhead() is extended to handle calls by only passing on the
actual call arguments (which is not all the operands).
This also eliminates a wrapper function with the same name.
review: Hal Finkel
llvm-svn: 293459
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 4c2de937aab..4645714faeb 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -3598,22 +3598,6 @@ static Value *addFastMathFlag(Value *V) { return V; } -/// \brief Estimate the overhead of scalarizing an Instruction based on the -/// types of its operands and return value. -static unsigned getScalarizationOverhead(SmallVectorImpl<Type *> &OpTys, - Type *RetTy, - const TargetTransformInfo &TTI) { - unsigned ScalarizationCost = 0; - - if (!RetTy->isVoidTy()) - ScalarizationCost += TTI.getScalarizationOverhead(RetTy, true, false); - - for (Type *Ty : OpTys) - ScalarizationCost += TTI.getScalarizationOverhead(Ty, false, true); - - return ScalarizationCost; -} - /// \brief Estimate the overhead of scalarizing an instruction. This is a /// convenience wrapper for the type-based getScalarizationOverhead API. static unsigned getScalarizationOverhead(Instruction *I, unsigned VF, @@ -3626,8 +3610,13 @@ static unsigned getScalarizationOverhead(Instruction *I, unsigned VF, if (!RetTy->isVoidTy()) Cost += TTI.getScalarizationOverhead(RetTy, true, false); - SmallVector<const Value *, 4> Operands(I->operand_values()); - Cost += TTI.getOperandsScalarizationOverhead(Operands, VF); + if (CallInst *CI = dyn_cast<CallInst>(I)) { + SmallVector<const Value *, 4> Operands(CI->arg_operands()); + Cost += TTI.getOperandsScalarizationOverhead(Operands, VF); + } else { + SmallVector<const Value *, 4> Operands(I->operand_values()); + Cost += TTI.getOperandsScalarizationOverhead(Operands, VF); + } return Cost; } @@ -3662,7 +3651,7 @@ static unsigned getVectorCallCost(CallInst *CI, unsigned VF, // Compute costs of unpacking argument values for the scalar calls and // packing the return values to a vector. - unsigned ScalarizationCost = getScalarizationOverhead(Tys, RetTy, TTI); + unsigned ScalarizationCost = getScalarizationOverhead(CI, VF, TTI); unsigned Cost = ScalarCallCost * VF + ScalarizationCost; |