maths
maths copied to clipboard
Alignment 16 for Vec3f for better simd instructions?
I was wondering could a explicit alignment attribute for Vec3f improve code generation for SIMD instructions?
#ifdef _WIN32
__declspec(align(16))
#else
__attribute__ ((aligned (16)))
#endif
typedef Vec<3, float> Vec3f;
yeah if you have a use case for it and the codegen is better, seems like something other people might like as well.
I am using vec3f in other code bases which might be packed in structs so possibly something like AlignedVec3
type? or we could enable on a macro? just so it's not going to break existing code.
do you have any example code showing the improvement in codegen for the aligned types?
I yet have to do some digging and struct packing in my engine before can say if this is going to make a real difference.
but it seems like you can't align a typedef :/
would be good to get some test cases where it shows improvement and then its worth digging into what would be a nice way to add this support. Easiest way is just to enable the alignment on a macro so you can choose to use aligned or not