Skip to content

Instantly share code, notes, and snippets.

@ryutorion
Created August 17, 2021 04:56
Show Gist options
  • Save ryutorion/38158fa693870b6fed3581537fb33e77 to your computer and use it in GitHub Desktop.
Save ryutorion/38158fa693870b6fed3581537fb33e77 to your computer and use it in GitHub Desktop.
// /std:c++latest /O2
struct Quaternion
{
float x;
float y;
float z;
float w;
};
constexpr const Quaternion dot(const Quaternion & s, const Quaternion & t) noexcept
{
return Quaternion(
s.x * t.x,
s.y * t.y,
s.z * t.z,
s.w * t.w
);
}
// Quaternion const dot(Quaternion const &,Quaternion const &) PROC ; dot, COMDAT
// movups xmm1, XMMWORD PTR [rdx]
// mov rax, rcx
// movups xmm0, XMMWORD PTR [r8]
// mulps xmm1, xmm0
// movups XMMWORD PTR [rcx], xmm1
// ret 0
// Quaternion const dot(Quaternion const &,Quaternion const &) ENDP ; dot
struct alignas(16) Quaternion
{
float x;
float y;
float z;
float w;
};
// Quaternion const dot(Quaternion const &,Quaternion const &) PROC ; dot, COMDAT
// movss xmm0, DWORD PTR [rdx]
// mov rax, rcx
// movss xmm3, DWORD PTR [rdx+4]
// movss xmm2, DWORD PTR [rdx+8]
// movss xmm1, DWORD PTR [rdx+12]
// mulss xmm0, DWORD PTR [r8]
// mulss xmm3, DWORD PTR [r8+4]
// mulss xmm2, DWORD PTR [r8+8]
// mulss xmm1, DWORD PTR [r8+12]
// movss DWORD PTR [rcx], xmm0
// movss DWORD PTR [rcx+4], xmm3
// movss DWORD PTR [rcx+8], xmm2
// movss DWORD PTR [rcx+12], xmm1
// ret 0
// Quaternion const dot(Quaternion const &,Quaternion const &) ENDP ; dot
struct Quaternion
{
union
{
struct
{
float x;
float y;
float z;
float w;
};
__m128 value;
};
};
// Quaternion const dot(Quaternion const &,Quaternion const &) PROC ; dot, COMDAT
// movups xmm1, XMMWORD PTR [rdx]
// mov rax, rcx
// movups xmm0, XMMWORD PTR [r8]
// mulps xmm1, xmm0
// movups XMMWORD PTR [rcx], xmm1
// ret 0
// Quaternion const dot(Quaternion const &,Quaternion const &) ENDP ; dot
struct alignas(16) Quaternion
{
union
{
struct
{
float x;
float y;
float z;
float w;
};
__m128 value;
};
};
// Quaternion const dot(Quaternion const &,Quaternion const &) PROC ; dot, COMDAT
// movups xmm1, XMMWORD PTR [rdx]
// mov rax, rcx
// movups xmm0, XMMWORD PTR [r8]
// mulps xmm1, xmm0
// movups XMMWORD PTR [rcx], xmm1
// ret 0
// Quaternion const dot(Quaternion const &,Quaternion const &) ENDP ; dot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment