@@ -1698,8 +1698,7 @@ namespace xsimd
16981698 return self;
16991699 }
17001700 // 1) duplicate‐low‐half?
1701- constexpr bool dup_lo = detail::is_dup_lo (mask);
1702- XSIMD_IF_CONSTEXPR (dup_lo)
1701+ XSIMD_IF_CONSTEXPR (detail::is_dup_lo (mask))
17031702 {
17041703 // permute low half and broadcast
17051704 const auto lo = _mm_shufflelo_epi16 (self, imm_lo);
@@ -1708,8 +1707,7 @@ namespace xsimd
17081707 }
17091708
17101709 // 2) duplicate‐high‐half?
1711- constexpr bool dup_hi = detail::is_dup_hi (mask);
1712- XSIMD_IF_CONSTEXPR (dup_hi)
1710+ XSIMD_IF_CONSTEXPR (detail::is_dup_hi (mask))
17131711 {
17141712 // permute high half and broadcast
17151713 const auto hi = _mm_shufflehi_epi16 (self, imm_lo);
@@ -1725,26 +1723,28 @@ namespace xsimd
17251723 _mm_shufflelo_epi16 (self, imm_hi), // permute words 0-3 (hi pattern)
17261724 _mm_shufflelo_epi16 (self, imm_hi));
17271725
1728- const auto hi0_all = [&]
1726+ __m128i hi0_all;
1727+ XSIMD_IF_CONSTEXPR (!detail::is_identity<uint16_t , V0, V1, V2, V3>())
17291728 {
1730- XSIMD_IF_CONSTEXPR (detail::is_identity<uint32_t , V0, V1, V2, V3>())
1731- {
1732- return _mm_unpackhi_epi64 (self, self);
1733- }
1734- __m128i hi = _mm_shufflehi_epi16 (self, imm_lo); // permute 4-7
1735- return _mm_unpackhi_epi64 (hi, hi); // broadcast
1736- }();
1729+ __m128i hi = _mm_shufflehi_epi16 (self, imm_lo);
1730+ hi0_all = _mm_unpackhi_epi64 (hi, hi);
1731+ }
1732+ else
1733+ {
1734+ // if the “low-pattern” is identity in the high half, just keep it
1735+ hi0_all = _mm_unpackhi_epi64 (self, self);
1736+ }
17371737
1738- // ----- build hi1_all ---------------------------------------------------
1739- const auto hi1_all = [&]
1738+ __m128i hi1_all;
1739+ XSIMD_IF_CONSTEXPR (!detail::is_identity< int32_t , V4 - 4 , V5 - 4 , V6 - 4 , V7 - 4 >())
17401740 {
1741- XSIMD_IF_CONSTEXPR (detail::is_identity<int32_t , V4 - 4 , V5 - 4 , V6 - 4 , V7 - 4 >())
1742- {
1743- return _mm_unpackhi_epi64 (self, self);
1744- }
17451741 __m128i hi = _mm_shufflehi_epi16 (self, imm_hi);
1746- return _mm_unpackhi_epi64 (hi, hi);
1747- }();
1742+ hi1_all = _mm_unpackhi_epi64 (hi, hi);
1743+ }
1744+ else
1745+ {
1746+ hi1_all = _mm_unpackhi_epi64 (self, self);
1747+ }
17481748
17491749 // merge halves
17501750 const auto low_all = _mm_unpacklo_epi64 (lo0_all, lo1_all);
0 commit comments