title: SSE instruction MOVSD (extended: floating point scalar & vector operations on x86, x86-64)
body: <p>I am somehow confused by the MOVSD assembly instruction. I wrote some numerical code computing some matrix multiplication, simply using ordinary C code with no SSE intrinsics. I do not even include the header file for SSE2 intrinsics  for compilation. But when I check the assembler output, I see that:</p>
  
  <p>1) 128-bit vector registers XMM are used;
  2) SSE2 instruction MOVSD is invoked.</p>
  
  <p>I understand that MOVSD essentially operates on single double precision floating point. It only uses the lower 64-bit of an XMM register and set the upper 64-bit 0. But I just don't understand two things:</p>
  
  <p>1) I never give the compiler any hint for using SSE2. Plus, I am using GCC not intel compiler. As far as I know, intel compiler will automatically seek opportunities for vectorization, but GCC will not. So how does GCC know to use MOVSD?? Or, has this x86 instruction been around long before SSE instruction set, and the _mm_load_sd() intrinsics in SSE2 is just to provide backward compatibility for using XMM registers for scalar computation?</p>
  
  <p>2) Why does not the compiler use other floating point registers, either the 80-bit floating point stack, or 64-bit floating point registers?? Why must it take the toll using XMM register (by setting upper 64-bit 0 and essentially wasting that storage)? Does XMM do provide faster access??</p>
  
  <hr>
  
  <p>By the way, I have another question regarding SSE2. I just can't see the difference between _mm_store_sd() and _mm_storel_sd(). Both store the lower 64-bit value to an address. What is the difference? Performance difference?? Alignment difference??</p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p><strong>Update 1:</strong></p>
  
  <p>OKAY, obviously when I first asked this question, I lacked some basic knowledge on how a CPU manages floating point operations. So experts tend to think my question is non-sense. Since I did not include even the shortest sample C code, people might think this question vague as well. Here I would provide <a href="https://stackoverflow.com/a/36121889/4891738">a review</a> as an answer, which hopefully will be useful to any people unclear about the floating point operations on modern CPUs.</p>