[PATCH] Include legalization cost when computing scalarization cost
Raul Silvera
rsilvera at google.com
Thu Mar 6 18:58:21 PST 2014
Thanks, Arnold. I think that's a good point. This overhead is not limited
to scalarization, but to any use of these instructions.
I'll update my patch with your suggestions (with .first) unless others have
objections.
On Thu, Mar 6, 2014 at 6:48 PM, Arnold Schwaighofer <aschwaighofer at apple.com
> wrote:
>
> On Mar 6, 2014, at 5:11 PM, Raul Silvera <rsilvera at google.com> wrote:
> > Index: lib/CodeGen/BasicTargetTransformInfo.cpp
> > ===================================================================
> > --- lib/CodeGen/BasicTargetTransformInfo.cpp
> > +++ lib/CodeGen/BasicTargetTransformInfo.cpp
> > @@ -20,7 +20,6 @@
> > #include "llvm/Analysis/TargetTransformInfo.h"
> > #include "llvm/Target/TargetLowering.h"
> > #include <utility>
> > -
> > using namespace llvm;
> >
> > namespace {
> > @@ -206,12 +205,19 @@
> > bool Extract) const {
> > assert (Ty->isVectorTy() && "Can only scalarize vectors");
> > unsigned Cost = 0;
> > -
> > - for (int i = 0, e = Ty->getVectorNumElements(); i < e; ++i) {
> > - if (Insert)
> > - Cost += TopTTI->getVectorInstrCost(Instruction::InsertElement,
> Ty, i);
> > - if (Extract)
> > - Cost += TopTTI->getVectorInstrCost(Instruction::ExtractElement,
> Ty, i);
> > + VectorType *VecTy = cast<VectorType>(Ty);
> > + std::pair<unsigned, MVT> LT =
> > + getTLI()->getTypeLegalizationCost(VecTy->getElementType());
> > +
> > + for (int i = 0, e = VecTy->getVectorNumElements(); i < e; ++i) {
> > + if (Insert) {
> > + Cost += LT.first *
> > + TopTTI->getVectorInstrCost(Instruction::InsertElement,
> VecTy, i);
> > + }
> > + if (Extract) {
> > + Cost += LT.first *
> > + TopTTI->getVectorInstrCost(Instruction::ExtractElement,
> VecTy, i);
> > + }
>
> Why do we want to do it at this (higher) level? I think,
> getVectorInstrCost() should have included the type legalization cost of the
> scalar type.
>
> unsigned BasicTTI::getVectorInstrCost(unsigned Opcode, Type *Val,
> unsigned Index) const {
> return getTLI().getTypeLegalizationCost(Ty->getScalarType()).second;
> }
>
>
--
Raúl E. Silvera
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140306/c1644292/attachment.html>
More information about the llvm-commits
mailing list