[cfe-commits] [PATCH][Review request] correct initialization of AltiVec vectors
Anton Yartsev
anton.yartsev at gmail.com
Tue Jan 25 13:45:12 PST 2011
On 17.01.2011 21:59, Douglas Gregor wrote:
> On Dec 29, 2010, at 4:14 PM, Anton Yartsev wrote:
>
>> Hi all,
>>
>> made changes according to the rules for the '(...)' form of vector initialization in AltiVec: the number of initializers must be one or must match the size of the vector. If a single value is specified in the initializer then it will be replicated to all the components of the vector.
>>
>> Can I commit the patch?
> + // '(...)' form of vector initialization in AltiVec: the number of
> + // initializers must be one or must match the size of the vector.
> + // If a single value is specified in the initializer then it will be
> + // replicated to all the components of the vector
> + if (Ty->getAs<VectorType>()->getVectorKind() ==
> + VectorType::AltiVecVector) {
> + unsigned numElems = Ty->getAs<VectorType>()->getNumElements();
> + // The number of initializers must be one or must match the size of the
> + // vector. If a single value is specified in the initializer then it will
> + // be replicated to all the components of the vector
> + if (PE->getNumExprs() == 1) {
> + Expr* initExpr = PE->getExpr(0);
> + for (unsigned i = 0; i != numElems; ++i)
> + initExprs.push_back(initExpr);
>
> This is effectively just a vector splat, so why not model it as an explicit C-style cast with kind CK_VectorSplat? That would more accurately describe what's happening than making this look like a vector initialization.
>
> - Doug
Done!
This solution, however, does not work in global scope for some reason.
Investigating the problem.
--
Anton
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: AltiVec_vector_init_fix_2.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110126/364740b4/attachment.ksh>
More information about the cfe-commits
mailing list