-
Notifications
You must be signed in to change notification settings - Fork 435
Fix ICX segfault caused by unconditional ARM64 SIMD wrapper types #621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stefanatwork
wants to merge
3
commits into
master
Choose a base branch
from
fix/arm64-simd-wrapper-icx-segfault
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,17 @@ namespace embree | |
| typedef vfloat4 Float; | ||
|
|
||
| enum { size = 4 }; // number of SIMD elements | ||
| // The __m128_wrapper indirection is only required to work around an | ||
| // MSVC/ARM64 overload-ambiguity issue (__m128 and __m128i both alias | ||
| // __n128 there). On all other platforms we keep the plain __m128 union | ||
| // member, which is what x86 and non-MSVC ARM64 builds have always used | ||
| // (see simd_wrapper_types.h); wrapping it unconditionally previously | ||
| // caused miscompiles/segfaults with some optimizing compilers (e.g. ICX). | ||
| #if defined(_MSC_VER) && defined(_M_ARM64) | ||
| union { __m128_wrapper v; int i[4]; }; // data | ||
| #else | ||
| union { __m128 v; int i[4]; }; // data | ||
| #endif | ||
|
|
||
| //////////////////////////////////////////////////////////////////////////////// | ||
| /// Constructors, Assignment & Cast Operators | ||
|
|
@@ -37,11 +47,22 @@ namespace embree | |
| __forceinline vboolf4& operator =(const vboolf4& other) { v = other.v; return *this; } | ||
|
|
||
| __forceinline vboolf(__m128 input) : v(input) {} | ||
| #if defined(_MSC_VER) && defined(_M_ARM64) | ||
| __forceinline operator const __m128&() const { return v.data; } | ||
| #if !defined(__EMSCRIPTEN__) | ||
| __forceinline const __m128i m128i() const { return _mm_castps_si128(v.data); } | ||
| __forceinline const __m128d m128d() const { return _mm_castps_pd(v.data); } | ||
| #endif | ||
| #else | ||
| __forceinline operator const __m128&() const { return v; } | ||
| #if !defined(__EMSCRIPTEN__) | ||
| __forceinline operator const __m128i() const { return _mm_castps_si128(v); } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we add this operator only in that case? We should now only go through new functions. |
||
| __forceinline operator const __m128d() const { return _mm_castps_pd(v); } | ||
| /* kept for source compatibility with code that calls .m128i()/.m128d() explicitly */ | ||
| __forceinline const __m128i m128i() const { return _mm_castps_si128(v); } | ||
| __forceinline const __m128d m128d() const { return _mm_castps_pd(v); } | ||
| #endif | ||
| #endif | ||
|
|
||
| __forceinline vboolf(bool a) | ||
| : v(mm_lookupmask_ps[(size_t(a) << 3) | (size_t(a) << 2) | (size_t(a) << 1) | size_t(a)]) {} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One could just remove the .data here and the functions should also work without the wrapper, the wrapper has conversion operators to the base type