last day (15 days later) » 

9:13 PM
2
A: How to implement "_mm_storeu_epi64" without aliasing problems?

MysticialSSE intrinsics is one of those niche corner cases where you have to push the rules a bit. Since these intrinsics are compiler extensions (somewhat standardized by Intel), they are already outside the specification of the C and C++ language standards. So it's somewhat self-defeating to try to be ...

 
That's worth investigating. I'm not sure of the answer myself.
 
Note that SSE types were never intended to be stored in memory as-is in the first place. I don't know why the pointer type in the signature is __m128i *, but generally SSE and memory-backed variables don't mix well.
 
@Mehrdad I dunno, I regularly allocate arrays of __m128d and such. Typically as scratch memory.
 
@Nemo: I think SSE registers were made to be tied to registers, not to be stored directly into memory. That's why they have specialized functions for dealing with memory.
@Mysticial: Are you talking about statically-sized arrays or dynamic ones? If you mean static, aren't those implicitly still bound to registers (as spilling as allows anyway) rather than in memory? What I mean is that doing something that forces them to be stored in memory generally hasn't ended well for me (obviously implicit spill is fine though, and not something I can control anyway).
 
@Mehrdad Dynamic. Think (__m128d*)aligned_malloc(10000000 * sizeof(__m128d)). I do that a lot in apps/algorithms that are completely designed around the SIMD vector.
 
9:13 PM
@Mysticial: And you actually load and store them like regular variables too? I (and the compiler) don't really care about the pointer types per se, but storing/retrieving variables of SSE types from memory is what I'm concerned about (like __m128d *p = ...; *p = blah;)
 
@Mehrdad Yeah. In some of my code, SIMD vectors are no different than any other datatype. void func(__m128d *a,__m128d *b){a[0] = _mm_add_pd(a[0],b[0])}
 
@Mysticial: Which compiler? I've felt like I've gotten different results with _mm_loadXYZ and _mm_storeXYZ than with plain load/store within the language (for some reason plain memory operations seemed to be not optimized as well, but I can't recall a specific example to demonstrate).
 
@Mehrdad I've never noticed a difference - and definitely not in performance. The compiler needs to have that logic anyway to deal with register spills.
 
@Mysticial: Weird, ok. If I come across it again I'll let you know, because I'm sure I've seen weird stuff happen when I've tried that (in MSVC anyway).
@Mysticial: On that note, what's the point of having all those loadu/storeu intrinsics if we can just deal with memory directly?
 
@Mehrdad In the past, compilers generate aligned moves for direct access.
And they still do for all 128-bit SIMD.
Newer compilers on 256-bit will unconditionally generate unaligned moves (even if you use an unaligned intrinsic) because the hardware can perform an unaligned move on an aligned address as fast as an aligned move.
 

  last day (15 days later) »