Repository: opencv/opencv
File: modules/core/include/opencv2/core/vsx_utils.hpp (C++)

Code before:
// same as vec_xxpermdi
#   undef vec_vbpermq
    VSX_IMPL_2VRG(vec_udword2, vec_uchar16, vbpermq, vec_vbpermq)
    VSX_IMPL_2VRG(vec_dword2,  vec_char16, vbpermq, vec_vbpermq)
#else
#   define vec_permi vec_xxpermdi
#endif // __GNUG__ < 5

// shift left double by word immediate
#ifndef vec_sldw
#   define vec_sldw __builtin_vsx_xxsldwi
#endif

// vector population count
VSX_IMPL_1VRG(vec_uchar16, vec_uchar16, vpopcntb, vec_popcntu)
VSX_IMPL_1VRG(vec_uchar16, vec_char16,  vpopcntb, vec_popcntu)
VSX_IMPL_1VRG(vec_ushort8, vec_ushort8, vpopcnth, vec_popcntu)
VSX_IMPL_1VRG(vec_ushort8, vec_short8,  vpopcnth, vec_popcntu)
VSX_IMPL_1VRG(vec_uint4,   vec_uint4,   vpopcntw, vec_popcntu)
VSX_IMPL_1VRG(vec_uint4,   vec_int4,    vpopcntw, vec_popcntu)
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)

// converts word and doubleword to double-precision
#undef vec_ctd
VSX_IMPL_1RG(vec_double2, vec_int4,    xvcvsxwdp, vec_ctdo)
VSX_IMPL_1RG(vec_double2, vec_uint4,   xvcvuxwdp, vec_ctdo)
VSX_IMPL_1RG(vec_double2, vec_dword2,  xvcvsxddp, vec_ctd)
VSX_IMPL_1RG(vec_double2, vec_udword2, xvcvuxddp, vec_ctd)

// converts word and doubleword to single-precision
#undef vec_ctf
VSX_IMPL_1RG(vec_float4, vec_int4,    xvcvsxwsp, vec_ctf)
VSX_IMPL_1RG(vec_float4, vec_uint4,   xvcvuxwsp, vec_ctf)
VSX_IMPL_1RG(vec_float4, vec_dword2,  xvcvsxdsp, vec_ctfo)
VSX_IMPL_1RG(vec_float4, vec_udword2, xvcvuxdsp, vec_ctfo)

// converts single and double precision to signed word
#undef vec_cts
VSX_IMPL_1RG(vec_int4,  vec_double2, xvcvdpsxws, vec_ctso)
VSX_IMPL_1RG(vec_int4,  vec_float4,  xvcvspsxws, vec_cts)

// converts single and double precision to unsigned word
#undef vec_ctu
VSX_IMPL_1RG(vec_uint4, vec_double2, xvcvdpuxws, vec_ctuo)
VSX_IMPL_1RG(vec_uint4, vec_float4,  xvcvspuxws, vec_ctu)


Review comment (suggestion):
this has an extra parenthesis
```suggestion
#if defined(__POWER10__) || (defined(__powerpc64__) && defined(__ARCH_PWR10__))
```

Code after:
// same as vec_xxpermdi
#   undef vec_vbpermq
    VSX_IMPL_2VRG(vec_udword2, vec_uchar16, vbpermq, vec_vbpermq)
    VSX_IMPL_2VRG(vec_dword2,  vec_char16, vbpermq, vec_vbpermq)
#else
#   define vec_permi vec_xxpermdi
#endif // __GNUG__ < 5

// shift left double by word immediate
#ifndef vec_sldw
#   define vec_sldw __builtin_vsx_xxsldwi
#endif

// vector population count
VSX_IMPL_1VRG(vec_uchar16, vec_uchar16, vpopcntb, vec_popcntu)
VSX_IMPL_1VRG(vec_uchar16, vec_char16,  vpopcntb, vec_popcntu)
VSX_IMPL_1VRG(vec_ushort8, vec_ushort8, vpopcnth, vec_popcntu)
VSX_IMPL_1VRG(vec_ushort8, vec_short8,  vpopcnth, vec_popcntu)
VSX_IMPL_1VRG(vec_uint4,   vec_uint4,   vpopcntw, vec_popcntu)
VSX_IMPL_1VRG(vec_uint4,   vec_int4,    vpopcntw, vec_popcntu)
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
// 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
VSX_IMPL_1RG(vec_double2, vec_int4,    xvcvsxwdp, vec_ctdo)
VSX_IMPL_1RG(vec_double2, vec_uint4,   xvcvuxwdp, vec_ctdo)
VSX_IMPL_1RG(vec_double2, vec_dword2,  xvcvsxddp, vec_ctd)