[cfe-commits] r129617 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl

Tanya Lattner tonic at nondot.org
Fri Apr 15 15:42:59 PDT 2011


Author: tbrethou
Date: Fri Apr 15 17:42:59 2011
New Revision: 129617

URL: http://llvm.org/viewvc/llvm-project?rev=129617&view=rev
Log:
Fix bug in vector initializer when initializing a vector with another vector.
Add test case.

Added:
    cfe/trunk/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl
Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=129617&r1=129616&r2=129617&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Apr 15 17:42:59 2011
@@ -841,6 +841,12 @@
   // becomes every element of the vector, not just the first.
   // This is the behavior described in the IBM AltiVec documentation.
   if (NumInits == 1) {
+    
+    // Handle the case where the vector is initialized by a another 
+    // vector (OpenCL 6.1.6).
+    if (E->getInit(0)->getType()->isVectorType())
+      return this->Visit(const_cast<Expr*>(E->getInit(0)));
+    
     APValue InitValue;
     if (EltTy->isIntegerType()) {
       llvm::APSInt sInt(32);

Added: cfe/trunk/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl?rev=129617&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl Fri Apr 15 17:42:59 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -o %t
+
+typedef __attribute__((ext_vector_type(8)))  unsigned char uchar8;
+typedef __attribute__((ext_vector_type(4)))  unsigned long ulong4;
+typedef __attribute__((ext_vector_type(16))) unsigned char uchar16;
+
+// OpenCL allows vectors to be initialized by vectors Handle bug in
+// VisitInitListExpr for this case below.
+void foo( ulong4 v )
+{
+  uchar8 val[4] = {{(uchar8){((uchar16)(v.lo)).lo}}};
+}
\ No newline at end of file





More information about the cfe-commits mailing list