[PATCH] D15721: [Sema] Fix ICE on casting a vector of bools to a vector of T

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 26 04:30:37 PST 2016


Anastasia added a comment.

OpenCL side seems fine! Thanks for adding OpenCL diagnostic btw. I think we will also need to forbid the invalid conversions too at some point.


================
Comment at: lib/Sema/SemaExpr.cpp:5715
@@ +5714,3 @@
+  // when compiling code as e.g. C++)
+  uint64_t srcEltSize =
+      srcEltTy->isBooleanType() ? 1 : Context.getTypeSize(srcEltTy);
----------------
Ok, I see now. I think your code here makes sense.

I am just generally a bit confused about how it should work. If I look at a slightly different example:

  typedef __attribute__((__ext_vector_type__(4))) bool BoolVector; 
  typedef __attribute__((__ext_vector_type__(1))) int IntVector;

  int main() {
    BoolVector bv;
    bool b=1;
    bv.s1 = b;
  }

this generates in IR:
  store <4 x i1> %2, <4 x i1>* %bv

seems a bit odd to see a store of 4 bits. Would it be changed by a middlend/backend then?

================
Comment at: lib/Sema/SemaType.cpp:2191
@@ +2190,3 @@
+  // Additionally, OpenCL prohibits vectors of booleans (they're considered a
+  // reserved data type under Section 6.1.4), but we do allow their use outside
+  // of OpenCL.
----------------
Could you change (there can be differences depending on a language version):

under Section 6.1.4 -> OpenCL v2.0 s6.1.4


http://reviews.llvm.org/D15721





More information about the cfe-commits mailing list