Clang generally treats booleans as 8-bit types, but lowers them to 1-bit types. This means we currently happily accept C++ code like:
typedef __attribute__((__ext_vector_type__(4))) bool BoolVector; typedef __attribute__((__ext_vector_type__(1))) int IntVector; int main() { BoolVector bv; IntVector iv = (IntVector)bv; }
...And lower it to a cast from a [4 x i1] to a [1 x i32]. Which gives us a nice greeting in the form of an ICE.
ISTM that bools are only a valid element type in OpenCL vectors. The spec doesn't outline a definitive size for a bool (only that it must be able to support a 0 or 1), so I'm assuming that lowering to a vector of i1 is fine.
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:
this generates in IR:
seems a bit odd to see a store of 4 bits. Would it be changed by a middlend/backend then?