Can the compiler make automatic use of SSE2 while optimisations are disabled?
When optimisations are disabled, does the /arch:SSE2 flag mean anything?
I've been given the task of squeezing more performance out of our software. Unfortunately, release builds are done using the debug settings, and attempts to argue for the case of optimisation have been unsuccessful so far.
Compiling for x86 with compiler flags /ZI /Od /arch:SSE2 /FAs
. The generated assembly shows that the compiler is not making use of SSE2
. Is this because optimisation is disabled?
In the code, there are a few situations similar to this:
char* begin = &bufferObject;
char* end = begin + sizeof(bufferObject);
char result;
while ( begin != end ) {
result ^= *begin++;
}
I'd like to have the compiler vectorise this operation for me, but it doesn't; I suspect optimisation needs to be enabled.
I hand-coded two solutions: one using an inline __asm
block, and the other using the SSE2 intrinsicts defined in <emmintrin.h>
. I'd prefer not to rely on this.
Update
Further to the questions above, I would like calls to library functions, like memcpy
, to use the provided vectorised versions when appropriate. Looking at the assembly code for memcpy
, I can see that there is a function called _VEC_memcpy
which makes use of SSE2
for faster copying. The block which decides whether to branch to this routine or not is this:
; First, see if we can use a "fast" copy SSE2 routine
; block size greater than min threshold?
cmp ecx,080h
jb Dword_align
; SSE2 supported?
cmp DWORD PTR __sse2_available,0
je Dword_align
; alignments equal?
push edi
push esi
and edi,15
and esi,15
cmp edi,esi
pop esi
pop edi
jne Dword_align
; do fast SSE2 copy, params already set
jmp _VEC_memcpy
I don't think that _VEC_memcpy
is being called... ever.