thebennybox-Community / Community-Compiler

MIT License
16 stars 5 forks source link

Vectorcall #33

Open davidgarland opened 6 years ago

davidgarland commented 6 years ago

Vectorcall is a calling convention for x86 much like fastcall in which vectors are allowed to be passed by the XMM, YMM, or ZMM registers to functions directly. This results in huge speedups, as it allows you not only the scaling speed increase of SIMD but also makes them faster to reach, as not only are they even closer to the CPU than cache normally is, but they also don't have the other associated downsides such as cache misses. Due to the aforementioned cache misses, many game developers write off SIMD as a waste of time for anything other than a 4-dimensional vector or when doing bundled operations-- but vectorcall fixes this issue.

For an example of a vectorcall function in C, using the __attribute__((vector_type(SIZE))) extension:

https://godbolt.org/g/5vRScm

And now the version without vectorcall:

https://godbolt.org/g/L1UH6e

(Note that GCC was used here because Clang is much better than GCC at auto vectorization, so I wanted to highlight the difference between vectorcall and fastcall here.)

Myvar commented 6 years ago

Awesome when we get to the IL compiling i will add this to the project bord thx, for you input.

Myvar commented 6 years ago

This is a complicated problem im not quite sure how to make this work on a cross platfrom situation, i will think on it