You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am dealing with a codebase which copies data from a float_v type object to an float[] array. The code checks if there is sufficient size, say for 4 for __m128, to cast it to float_v or use gather with mask for partial load.
In that code I see the implementation as such, in a basic sample form:
Is the gather implementation in the else condition safe? I have seen mentions that casting from float* to __m128* is okay but the other way around is not safe. See for reference this stackoverflow answer and this stack overflow post
I feel like I should scatter or store to a float[4] array and then pass its address instead. Or is the current implementation safe?
Another question, which would be really helpful if you could answer:
I am not sure about the cast to reference type float_v& in the above implementation. It doesn't "feel" right. I can think of four different ways to load:
1.
I am dealing with a codebase which copies data from a
float_v
type object to anfloat[]
array. The code checks if there is sufficient size, say for 4 for__m128
, to cast it tofloat_v
or use gather with mask for partial load.In that code I see the implementation as such, in a basic sample form:
Problem
Is the gather implementation in the
else
condition safe? I have seen mentions that casting fromfloat*
to__m128*
is okay but the other way around is not safe. See for reference this stackoverflow answer and this stack overflow postI feel like I should
scatter
orstore
to afloat[4]
array and then pass its address instead. Or is the current implementation safe?Another question, which would be really helpful if you could answer:
I am not sure about the cast to reference type
float_v&
in the above implementation. It doesn't "feel" right. I can think of four different ways to load:1.
Which would be the "best way" or good practice from your expert perspective?
The text was updated successfully, but these errors were encountered: