   SSE instructions/Compiler optimization
  I'm just wondering in the most common x86 C++ compilers such as MSVC and GCC add SSE and other SIMD instructions during their optimizations.[Edited by - godsenddeath on November 19, 2010 12:05:28 PM]
  MSVC doesn't generate SIMD SSE instructions, unless you use the appropriate intrinsics. It will use non-SIMD SSE though if you ask for it in the options (or are compiling for x64).gcc can do some automatic conversion to SSE code under some circumstances, but in many cases you'll probably want to use intrinsics anyway. See http://gcc.gnu.org/projects/tree-ssa/vectorization.html   ;  In all but the most trivial of cases, any SIMD code requires you to restructure both data and algorithms.  The compiler won't do it for you.  That is simply not the job of the compiler or optimizer.  You wouldn't expect that you could write a bubble sort and have the optimizer change it to quicksort, so it is with parallel processing.  It might identify a specific instruction here or there, just as the optimizer might unroll a loop or use a strength-reduced operation, but it will not rewrite your algorithms.You must specifically write your programs to use parallel data structures and write your algorithm to run on the parallel data.   ;  Intel's compiler is about the best I've seen at making proper use of SIMD SSE.  GCC isn't bad.  VC++ doesn't even try.  The current state of 'state of the art' C++ compilers is pretty sad IMO.Also I'd be very careful with intrinsics with the VC++ compiler, as it often produces slower code with SSE intrinsics than with just plain old C++ code.  If speed is important, your best bet is to write the function in asm by hand, or better yet (if its available) use something like CUDA, Direct Compute, or OpenCL.   