<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">Thanks, Arnold. I think that's a good point. This overhead is not limited to scalarization, but to any use of these instructions.</div><div class="gmail_default" style="font-family:verdana,sans-serif">
<br></div><div class="gmail_default" style="font-family:verdana,sans-serif">I'll update my patch with your suggestions (with .first) unless others have objections.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Mar 6, 2014 at 6:48 PM, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On Mar 6, 2014, at 5:11 PM, Raul Silvera <<a href="mailto:rsilvera@google.com">rsilvera@google.com</a>> wrote:<br>
> Index: lib/CodeGen/BasicTargetTransformInfo.cpp<br>
> ===================================================================<br>
> --- lib/CodeGen/BasicTargetTransformInfo.cpp<br>
> +++ lib/CodeGen/BasicTargetTransformInfo.cpp<br>
> @@ -20,7 +20,6 @@<br>
> #include "llvm/Analysis/TargetTransformInfo.h"<br>
> #include "llvm/Target/TargetLowering.h"<br>
> #include <utility><br>
> -<br>
> using namespace llvm;<br>
><br>
> namespace {<br>
> @@ -206,12 +205,19 @@<br>
> bool Extract) const {<br>
> assert (Ty->isVectorTy() && "Can only scalarize vectors");<br>
> unsigned Cost = 0;<br>
> -<br>
> - for (int i = 0, e = Ty->getVectorNumElements(); i < e; ++i) {<br>
> - if (Insert)<br>
> - Cost += TopTTI->getVectorInstrCost(Instruction::InsertElement, Ty, i);<br>
> - if (Extract)<br>
> - Cost += TopTTI->getVectorInstrCost(Instruction::ExtractElement, Ty, i);<br>
> + VectorType *VecTy = cast<VectorType>(Ty);<br>
> + std::pair<unsigned, MVT> LT =<br>
> + getTLI()->getTypeLegalizationCost(VecTy->getElementType());<br>
> +<br>
> + for (int i = 0, e = VecTy->getVectorNumElements(); i < e; ++i) {<br>
> + if (Insert) {<br>
> + Cost += LT.first *<br>
> + TopTTI->getVectorInstrCost(Instruction::InsertElement, VecTy, i);<br>
> + }<br>
> + if (Extract) {<br>
> + Cost += LT.first *<br>
> + TopTTI->getVectorInstrCost(Instruction::ExtractElement, VecTy, i);<br>
> + }<br>
<br>
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.<br>
<br>
unsigned BasicTTI::getVectorInstrCost(unsigned Opcode, Type *Val,<br>
unsigned Index) const {<br>
return getTLI().getTypeLegalizationCost(Ty->getScalarType()).second;<br>
}<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div><font size="4" face="arial black, sans-serif" style="background-color:rgb(0,0,0)" color="#b45f06"> Raúl E. Silvera </font></div><div><br></div>
</div>
</div>