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
math ops fail to do int/float conversion or generate an error on SSE2 #66
Comments
Thanks for the bug report. Unfortunately I can't reproduce the issue on neither the master branch nor C++11 or C++98 versions of the 2.0 release. Which version of libsimdpp are you using? |
I'm at 2545b97 (libsimdpp-2.x branch, v2.0 tag). the problem appears to be isolated to xcode 8.3.3 and associated clang. In case it matters, I'm using SIMDPP_ARCH_X86_SSSE3, and using xcode's platform default vector set (which appears to be SSE 4.2). |
Turns out this is caused by the clang vector extension (corresponding GCC docs). The extension defines various operators for the native SIMD types such as
This API was probably supposed to be used with the native clang vector types that expose more information about the type of data within them. Extending this API to types such as With regards to libsimdpp, this revelation is unfortunate, because code like this will result in wrong behavior instead of failing to compile:
Unfortunately there seems no way to disable the operators provided by the vector extension. There is
As a replacement, a member function will be added which will enable the code to be rewritten like this:
|
Member function to retrieve native vector value to all vector types have been added in 40ba6dd. The usage of the old conversion operator throughout the library have been removed in ba136bf. Tests to verify that wrong conversions are no longer accepted have been added in in afd8708. The old conversion operators have been marked as deprecated in cac3857. The API will be removed some time in the future. If one wants to disable the old operators to avoid this bug, |
results in a single addps instruction for SSE2, as if b were a float32.
results in a compilation error, which is resolved by explicitly converting b with to_float32(). Presumably use of + should fail in the same was as use of add() (or even better would be to automatically convert between float/int just scalar operations would)
The text was updated successfully, but these errors were encountered: