0
0
mirror of https://github.com/opencv/opencv.git synced 2026-01-18 17:21:42 +01:00

Merge pull request #27990 from asmorkalov:as/power9_build_fix

Fix missing vec_cvfo on IBM POWER9 due to unavailable VSX float64 conversion #27990 

Replaces https://github.com/opencv/opencv/pull/27633
Closes https://github.com/opencv/opencv/issues/27635

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov
2025-11-10 12:11:24 +03:00
committed by GitHub
parent db207c88b0
commit 83026bfe87

View File

@@ -257,8 +257,27 @@ VSX_IMPL_1VRG(vec_udword2, vec_udword2, vpopcntd, vec_popcntu)
VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcntu)
// converts between single and double-precision
VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, vec_floate)
VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, vec_doubleo)
// vec_floate and vec_doubleo are available since Power10 and z14
#if defined(__POWER10__) || (defined(__powerpc64__) && defined(__ARCH_PWR10__)
// Use VSX double<->float conversion instructions (if supported by the architecture)
VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvfo, vec_floate)
VSX_REDIRECT_1RG(vec_double2, vec_float4, vec_cvfo, vec_doubleo)
#else
// Fallback: implement vec_cvfo using scalar operations (to ensure successful linking)
static inline vec_float4 vec_cvfo(const vec_double2& a)
{
float r0 = static_cast<float>(reinterpret_cast<const double*>(&a)[0]);
float r1 = static_cast<float>(reinterpret_cast<const double*>(&a)[1]);
return (vec_float4){r0, 0.f, r1, 0.f};
}
static inline vec_double2 vec_cvfo(const vec_float4& a)
{
double r0 = static_cast<double>(reinterpret_cast<const float*>(&a)[0]);
double r1 = static_cast<double>(reinterpret_cast<const float*>(&a)[2]);
return (vec_double2){r0, r1};
}
#endif
// converts word and doubleword to double-precision
#undef vec_ctd