13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPLICATION PERFORMANCE TOOLSExample 10-1. Storing Absolute Valuesint dst[1024], src[1024]for (i = 0; i < 1024; i++) {dst[i] = (src[i] >=0) ? src[i] : -src[i];}The following examples are illustrative of the likely differences of two compilerswitches.Example 10-2. Auto-Generated Code of Storing AbsolutesCompiler Switch QxWCompiler Switch QxTmovdqa xmm1, _src[eax*4]pxor xmm0, xmm0pcmpgtd xmm0, xmm1pxor xmm1, xmm0psubd xmm1, xmm0movdqa _dst[eax*4], xmm1add eax, 4cmp eax, 1024jb $B1$3pabsd xmm0, _src[eax*4]movdqa _dst[eax*4], xmm0add eax, 4cmp eax, 1024jb $B1$3Example 10-3. Changes Signsint dst[NUM], src[1024];for (i = 0; i < 1024; i++) {if (src[i] == 0){ dst[i] = 0; }else if (src[i] < 0){ dst[i] = -dst[i]; }}A-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!