diff --git a/glm/detail/simd_constexpr/vec.hpp b/glm/detail/simd_constexpr/vec.hpp index 4c60c291..a686e280 100644 --- a/glm/detail/simd_constexpr/vec.hpp +++ b/glm/detail/simd_constexpr/vec.hpp @@ -187,10 +187,31 @@ namespace glm template requires(std::is_same_v) inline vec compWiseTernary(vec v1, vec v2) { - GccVec_t condMask = std::bit_cast(elementArr); - auto gv1 = std::bit_cast>(v1.elementArr); - auto gv2 = std::bit_cast>(v2.elementArr); - return vec((condMask ? gv1 : gv2)); + if constexpr ( sizeof(Tx) == sizeof(int32_t) ) { + using GVec_t = typename detail::GccVExt::GccV; + GVec_t condMask = __builtin_convertvector(std::bit_cast(elementArr), GVec_t); + auto gv1 = std::bit_cast>(v1.elementArr); + auto gv2 = std::bit_cast>(v2.elementArr); + return vec((condMask ? gv1 : gv2)); + } else if constexpr ( sizeof(Tx) == sizeof(int64_t) ) { + using GVec_t = typename detail::GccVExt::GccV; + GVec_t condMask = __builtin_convertvector(std::bit_cast(elementArr), GVec_t); + auto gv1 = std::bit_cast>(v1.elementArr); + auto gv2 = std::bit_cast>(v2.elementArr); + return vec((condMask ? gv1 : gv2)); + } else if constexpr ( sizeof(Tx) == sizeof(int16_t) ) { + using GVec_t = typename detail::GccVExt::GccV; + GVec_t condMask = __builtin_convertvector(std::bit_cast(elementArr), GVec_t); + auto gv1 = std::bit_cast>(v1.elementArr); + auto gv2 = std::bit_cast>(v2.elementArr); + return vec((condMask ? gv1 : gv2)); + } else { + using GVec_t = typename detail::GccVExt::GccV; + GVec_t condMask = __builtin_convertvector(std::bit_cast(elementArr), GVec_t); + auto gv1 = std::bit_cast>(v1.elementArr); + auto gv2 = std::bit_cast>(v2.elementArr); + return vec((condMask ? gv1 : gv2)); + } } template