Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang __m128 won't work with DirectXMath #43

Closed
walbourn opened this issue Feb 5, 2017 · 2 comments
Closed

Clang __m128 won't work with DirectXMath #43

walbourn opened this issue Feb 5, 2017 · 2 comments
Assignees
Labels
conformance Related to supporting non-MSVC compilers

Comments

@walbourn
Copy link
Member

walbourn commented Feb 5, 2017

In a few places in the DirectXMath library, individual vector element access is done by V.m128_f32[i] / V.n128_u32[i] and V.m128_u32[i] / V.n128_u32[i] which lets the compiler do the 'spill' to memory automatically. Clang doesn't support this MSVC/Intel compiler-specific behavior in how __m128 is defined so won't build.

This impacts the following functions:

  • XMVectorGetByIndex

  • XMVectorGetByIndexPtr

  • XMVectorGetIntByIndex

  • XMVectorGetIntByIndexPtr

  • XMVectorSetByIndex

  • XMVectorSetByIndexPtr

  • XMVectorSetIntByIndex

@walbourn
Copy link
Member Author

walbourn commented Feb 5, 2017

The portable solution is to use an explicit union:

XMVECTORF32 U;
U.v = V;
return U.f[i];

Which should result in the same codegen on Visual C++. XMVectorSetIntByIndexPtr is already using this pattern.

See Get member of __m128 by index?

@walbourn walbourn added the conformance Related to supporting non-MSVC compilers label Feb 5, 2017
@walbourn
Copy link
Member Author

Fixed in master branch. See this commit

Will be included in a future release of DirectXMath

@walbourn walbourn self-assigned this Feb 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conformance Related to supporting non-MSVC compilers
Projects
None yet
Development

No branches or pull requests

1 participant