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
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to