Is it a correct assessment that compiling with -m32 and -mtune=native on a AMD64 machine will use 32 bits for pointers and hence slightly smaller data structures, and consequently a denser cache packing. My application (it is still in its design stage) will not need more than a GB of memory so a 32 bit address space should be fine. I am hoping to utilize the bit-shrunk data structures for more data in cache, and also the potential to use more registers for integer math. What I am trying to achieve is the best of both worlds, more registers by virtue of -mtune=native, but smaller pointers by -m32. Will the availability of extra registers be taken care of largely automatically or do I have to deal explicitly with sse. I would rather not.
Share
At least if I understand what you want, I don’t think the compiler is going to do the job for you. It’d going to produce either 32-bit or 64-bit code. With 64-bit code, the pointers will be 64 bits — if you want 32-bit pointers, you’re going to have to generate 32-bit code (with its commensurate limitations, such as on what registers it’ll use).
To get what you want, I’m pretty sure you’ll have to split the pointer up yourself: store a (probably 64-bit) base address, and inside your data structure, store offsets rather than complete addresses. You’ll need to add the base and offset together yourself before you attempt to de-reference though.