[LLVMdev] Making GEP into vector illegal?

Eli Friedman eli.friedman at gmail.com
Tue Oct 14 13:54:05 PDT 2008

On Tue, Oct 14, 2008 at 1:34 PM, Daniel M Gessel <gessel at apple.com> wrote:
> In Joe programmer language (i.e. C ;) ), are we basically talking
> about disallowing:
> float4 a;
> float* ptr_z = &a.z;
> ?

That's my reading as well; the argument for not allowing it is just to
make optimization easier.  We don't allow addressing individual bits
either, and compilers obviously have to work around that for

AFAIK, both clang and gcc currently don't allow constructs like "&a.z".

> Won't programmers just resort to:
> float4 a;
> float* ptr_z = (float*)(&a) + 3;
> ?

Maybe... although note that with gcc vector intrinsics, this violates
strict aliasing.  gcc does allow you to use a slightly more elaborate
workaround with a union, though.


More information about the llvm-dev mailing list