Possible duplicate:
Qt, GCC, SSE and stack alignment
I am converting a simulator from TinyPTC to WxWidgets. Some graphics routines are optimized using the built-in SSE features. During GUI initialization, the initial state is displayed once, and all SSE routines work fine. However, if I call them later from the event handler, I will get SIGSEGV.
At first I thought that these were some weird alignment problems, but this happens even for:
__m128i zero = _mm_setzero_si128();
When I replace SSE routines with non-optimized code, everything works fine.
I believe that event processing occurs in a different thread than initialization. Is there something to consider when using SSE from different threads? What else could cause this behavior?
SIGSEGV occurs with the instruction movdqa %xmm0, -40(%ebp)(there are several of them). If I compile with -O1, the instructions are movdqafully optimized and the program works fine. This seems to be a stack alignment issue, as already mentioned in the comments.
Here is the CodeLite command to compile:
g++ -c "x:/some/folder/sse.cpp" -g -O1 -Wall -std=gnu++0x -msse3
-mthreads -DHAVE_W32API_H -D__WXMSW__ -D__WXDEBUG__ -D_UNICODE
-ID:\CodeLite\wxWidgets\lib\gcc_dll\mswud -ID:\CodeLite\wxWidgets\include
-DWXUSINGDLL -Wno-ctor-dtor-privacy -pipe -fmessage-length=0 -o ./Debug/sse.o -I.
Anything unusual? Is it possible that WxWidgets is changing the alignment settings somewhere?
source
share