Handmade Hero»Forums»Code
55 posts
LLVM Extended Vectors
What are these "Extended Vectors" in LLVM used for? Are they the equivalent of the union syntax in MSVC to access individual floats in a vector? Or do they automatically emit the Intel intrinsic instructions when you operate on them?
Mārtiņš Možeiko
2562 posts / 2 projects
LLVM Extended Vectors
Edited by Mārtiņš Možeiko on
Afaik Extended Vectors are used only by OpenCL frontend in clang.
Regular CPU code for SSE/AVX instructions uses __vector_size__ attribute to define __m128, __m128i and other SSE/AVX vector types.

But you really don't need to worry about that. For clang compile you need to include x86intrin.h header and then you can use any intrinsic Casey is using. If you are compiling 32-bit code you will need to pass additional command line argument "-msse2" to allow compiler to generate actual SSE/SSE2 instructions. For 64-bit code it is implicit.
55 posts
LLVM Extended Vectors
Thank you. Yes, it was working already, I was just wondering what its purpose was after reading about it.

Thought I had included a link. For anyone who's curious: Vectors and Extended Vectors
Mārtiņš Možeiko
2562 posts / 2 projects
LLVM Extended Vectors
Edited by Mārtiņš Možeiko on
I checked, and I was wrong. Clang accepts ext_vector attribute also in C/C++ mode.
So that is pretty nice way how to generate your V2/V3/V4 types. With automatic swizzling for x/y/z/w components. That is if you are OK for depending exclusively on clang compiler (no gcc/msvc).