@@ -26,7 +26,17 @@ namespace embree
2626 typedef vfloat4 Float;
2727
2828 enum { size = 4 }; // number of SIMD elements
29+ // The __m128_wrapper indirection is only required to work around an
30+ // MSVC/ARM64 overload-ambiguity issue (__m128 and __m128i both alias
31+ // __n128 there). On all other platforms we keep the plain __m128 union
32+ // member, which is what x86 and non-MSVC ARM64 builds have always used
33+ // (see simd_wrapper_types.h); wrapping it unconditionally previously
34+ // caused miscompiles/segfaults with some optimizing compilers (e.g. ICX).
35+ #if defined(_MSC_VER) && defined(_M_ARM64)
2936 union { __m128_wrapper v; int i[4 ]; }; // data
37+ #else
38+ union { __m128 v; int i[4 ]; }; // data
39+ #endif
3040
3141 // //////////////////////////////////////////////////////////////////////////////
3242 // / Constructors, Assignment & Cast Operators
@@ -37,11 +47,22 @@ namespace embree
3747 __forceinline vboolf4& operator =(const vboolf4& other) { v = other.v ; return *this ; }
3848
3949 __forceinline vboolf (__m128 input) : v(input) {}
50+ #if defined(_MSC_VER) && defined(_M_ARM64)
4051 __forceinline operator const __m128&() const { return v.data ; }
4152 #if !defined(__EMSCRIPTEN__)
4253 __forceinline const __m128i m128i () const { return _mm_castps_si128 (v.data ); }
4354 __forceinline const __m128d m128d () const { return _mm_castps_pd (v.data ); }
4455 #endif
56+ #else
57+ __forceinline operator const __m128&() const { return v; }
58+ #if !defined(__EMSCRIPTEN__)
59+ __forceinline operator const __m128i () const { return _mm_castps_si128 (v); }
60+ __forceinline operator const __m128d () const { return _mm_castps_pd (v); }
61+ #endif
62+ /* kept for source compatibility with code that calls .m128i()/.m128d() explicitly */
63+ __forceinline const __m128i m128i () const { return _mm_castps_si128 (v); }
64+ __forceinline const __m128d m128d () const { return _mm_castps_pd (v); }
65+ #endif
4566
4667 __forceinline vboolf (bool a)
4768 : v(mm_lookupmask_ps[(size_t (a) << 3) | (size_t (a) << 2) | (size_t (a) << 1) | size_t(a)]) {}
0 commit comments