title: Compiling SSE intrinsics in GCC gives an error
body: <p>My SSE code works completely fine on Windows platform, but when I run this on Linux I am facing many issues. One amongst them is this:</p>
  
  <p>It's just a sample illustration of my code:</p>
  
  <pre><code>int main(int ref, int ref_two)
  
  {
  
   __128i a, b;
  
  a.m128i_u8[0] = ref;
  
  b.m128i_u8[0]  = ref_two;
  
  .
  
  .
  
  
  .
  
  .....
  
  }
  </code></pre>
  
  <p>Error 1:</p>
  
  <blockquote>
    <p>error : request for member 'm128i_u8' in something not a structure or union</p>
  </blockquote>
  
  <p>In this thread it gives the solution of to use appropriate _mm_set_XXX intrinsics instead of the above method as it only works on Microsoft.
  <a href="https://stackoverflow.com/questions/17516634/sse-intrinsics-compiling-msdn-code-with-gcc-error">SSE intrinsics compiling MSDN code with GCC error?</a></p>
  
  <p>I tried the above method mentioned in the thread I have replaced set instruction in my program but it is seriously affecting the performance of my application.</p>
  
  <p>My code is massive and it needs to be changed at 2000 places. So I am looking for better alternative without affecting the performance of my app.</p>
  
  <p>Recently I got this link from Intel, which says to use <code>-fms-diaelect</code> option to port it from windows to Linux.</p>
  
  <p><a href="http://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-7A69898B-BDBB-4AA9-9820-E4A590945903.htm" rel="nofollow noreferrer">http://software.intel.com/sites/products/documentation/doclib/iss/2013/compiler/cpp-lin/GUID-7A69898B-BDBB-4AA9-9820-E4A590945903.htm</a> </p>
  
  <p>Has anybody tried the above method?  Has anybody found the solution to porting large code to Linux?</p>
  
  <hr>
  
  <p>@Paul, here is my code and I have placed a timer to measure the time taken by both methods and the results were shocking.</p>
  
  <p>Code 1: 115 ms (Microsoft method to access elements directly)</p>
  
  <p>Code 2: 151 ms (using set instruction)</p>
  
  <p>It costed me a 36 ms when i used set in my code.</p>
  
  <p>NOTE: If I replace in single instruction of mine it takes 36 ms and imagine the performance degrade which I am going to get if I replace it 2000 times in my program.</p>
  
  <p>That's the reason I am looking for a better alternative other than set instruction</p>
  
  <p>Code 1:</p>
  
  <pre><code>__m128i array;
  unsigned char* temp_src;
  unsigned char* temp_dst;
  
  for (i=0; i&lt; 20; i++)
  
  {
  
  for (j=0; j&lt; 1600; j+= 16)
  
   {
     Timerstart(&amp;x);  
     array =  _mm_loadu_si128 ((__m128i *)(src));
     array.m128i_u8[0] =  36;
     y+ = Timerstop(x);
     _mm_store_si128( (__m128i *)temp_dst,array);
  
    }
   }
  </code></pre>
  
  <p>Code2:</p>
  
  <pre><code> __m128i array;
   unsigned char* temp_src;
   unsigned char* temp_dst;
  
   for (i=0; i&lt; 20; i++)
   {
   for (j=0; j&lt; 1600; j+= 16)
  
   {
  
  
  
         Timerstart(&amp;x);
         array = _mm_set_epi8(*(src+15),*(src+14),*(src+13),*(src+12),
                               *(src+11),*(src+10),*(src+9), *(src+8),
                           *(src+7), *(src+6), *(src+5), *(src+4),
                               *(src+3), *(src+2), *(src+1), 36 );
         y+ = Timerstop(x);
  
         _mm_store_si128( (__m128i *)temp_dst,array);
  
    }
  }
  </code></pre>