Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

SSE intstruction error

inteleverywhere
Beginner
95 Views

if a register has to be filled with data upto an arbitrary byte/word/dword position is it possible? for example:

if cnt = 0 or 1 or 2 or 3. how can the following be done

for (int i=0; i < cnt; i++)

{

Register = _mm_insert_epi32(Register, i);

Register1 = _mm_slli_si128(Register1, i);

}

Both are being dissallowed since i is required to be a constant value. Is there a workaround?

suppose at run time only two values are to be filled (cnt = 2).

Thanks

Deepak

0 Kudos
1 Reply
JenniferJ
Moderator
95 Views
Try to avoid the "for" statement. so like below:

[cpp]switch (cnt)  { 
   case 1:
        Register  = _mm_insert_epi32(Register, 1); 
        Register1 = _mm_slli_si128(Register1, 1);
        break;
  case 2:
        Register  = _mm_insert_epi32(Register, 1); 
        Register1 = _mm_slli_si128(Register1, 1);
        //! Second loop instance
        Register  = _mm_insert_epi32(Register, 2); 
        Register1 = _mm_slli_si128(Register1, 2);
        break;
}

[/cpp]

Reply