[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #9 from ubizjak at gmail dot com 2009-06-25 09:03 --- *** This bug has been marked as a duplicate of 21920 *** -- ubizjak at gmail dot com changed: What|Removed |Added Status|NEW |RESOLVED Resolution||DUPLICATE http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #1 from gael dot guennebaud at gmail dot com 2009-06-24 08:07 --- Created an attachment (id=18055) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=18055action=view) a complete example showing the problem usage: Works: g++ -O3 instr_dependency.cpp -o instr_dependency ./instr_dependency Fails: g++ -O3 instr_dependency.cpp -o instr_dependency -DFAST ./instr_dependency -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #2 from rguenth at gcc dot gnu dot org 2009-06-24 09:48 --- I can't verify it (you do not provide complete source that can be compiled), but I think this is a duplicate of PR40141 which is fixed in GCC 4.4. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||rguenth at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #3 from gael dot guennebaud at gmail dot com 2009-06-24 10:53 --- There is a compilable example attached to comment #1. Furthermore, I can reproduce the problem with gcc 4.1.3, 4.2.4, 4.3.2, and 4.4.0, so I don't think it is a duplicate of PR40141. FYI, in the meantime I workaround the issue using inline assembly: inline __m128 ploadu(const float* from) { __m128 res; asm(movsd %[from0], %[r] : [r] =x (res) : [from0] m (*from), [dummy] m (*(from+1)) ); asm(movhps %[from2], %[r] : [r] +x (res) : [from2] m (*(from+2)), [dummy] m (*(from+3)) ); return res; } but that's not as portable as intrinsics. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #4 from gael dot guennebaud at gmail dot com 2009-06-24 11:12 --- some additional info: - compiling with -fno-strict-aliasing fix the issue, so perhaps this is not a real bug but a feature ? - on the other hand using the may_alias type attribute for casting does not help: inline __m128 ploadu(const float* from) { typedef double __attribute__((may_alias)) doubleA; typedef __m128 __attribute__((may_alias)) __m128A; __m128 r; r = (__m128A)(_mm_load_sd( (const doubleA*)(from) )); r = _mm_loadh_pi(r, (const __m64*)(from+2)); return r; } I guess this is because the const doubleA* is then casted to a const double* when calling the _mm_load_sd() function. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #5 from rguenth at gcc dot gnu dot org 2009-06-24 11:23 --- There are aliasing issues with your code / the intrinsics implementation: float data[4] = {1, 2, 3, 4}; ... r = _mm_castpd_ps(_mm_load_sd((double*)(from))); ends up loading from float data via a pointer to double. That is invalid unless the intrinsic specifies it should work ok in which case it better had implemented counter-measures here: data[0] ={v} 1.0e+0; data[1] ={v} 2.0e+0; data[2] ={v} 3.0e+0; data[3] ={v} 4.0e+0; from.92_14 = (const double *) data[0]; D.25303_15 = *from.92_14; D.25304_16 = {D.25303_15, 0.0}; r_17 = VIEW_CONVERT_EXPR__m128(D.25304_16); I would suggest using typedef double __attribute__((may_alias)) aliased_double; r = _mm_castpd_ps(_mm_set_sd (*(aliased_double *)from)); instead. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #7 from ubizjak at gmail dot com 2009-06-24 11:57 --- Adding x86 intrinsic expert... -- ubizjak at gmail dot com changed: What|Removed |Added CC||hjl dot tools at gmail dot ||com Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2009-06-24 11:57:04 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537
[Bug target/40537] wrong instr. dependency with some SSE intrinsics
--- Comment #8 from hjl dot tools at gmail dot com 2009-06-24 13:09 --- (In reply to comment #6) _mm_load_sd( (const doubleA*)(from) ) does not work because the prototype of _mm_load_sd does not have a type with the may-alias attribute, so it gets stripped again. I think movsd/movhpd intrinsics with union of double/float or movlps/movhps intrinsics should be used. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40537