Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

MSVC ICC instruction Exception

inteleverywhere
Beginner
456 Views
Could someone please point out what the problem is with the following snippet. An exception occurs in MSVC.

__m128i R0, R1;
__m128i *R0P1, *R0P2;
__m128i *R1P1, *R1P2;

char buf_chr[20] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'
};

R0 = _mm_loadu_si128((__m128i*) (buf_chr));
R1 = _mm_loadu_si128((__m128i*) (buf_int));

R0P1 = (__m128i *) (buf_chr);
R0P2 = (__m128i *) (buf_chr);

R0 = _mm_add_epi8(R0, R1);

*R0P1 = _mm_add_epi8((__m128i) *R0P1, (__m128i) *R0P2); // ---------> Exception occurs here.

Is there a way to do the addition if I have a register used as a pointer. Can de-referencing be done by using *?This question arises because the following statements pass without incident!

R0P1++;
R0P2++;

Thanks and Regards
Deepak

0 Kudos
6 Replies
inteleverywhere
Beginner
456 Views
Please ignore the use of buf_int. That is not a problem. I have an array by that name. I forgot to paste it with the message. The problem is something else.

Reg
Deepak
0 Kudos
inteleverywhere
Beginner
456 Views
No reply anybody there!!
0 Kudos
Yang_W_Intel
Employee
456 Views
What is your compilation option?
-Yang
0 Kudos
Yang_W_Intel
Employee
456 Views
Please check if the address of buf_chr is 16 bytes aligned. If not, there will be an exception.
0 Kudos
inteleverywhere
Beginner
456 Views

You are right. But what if the data address is arbitrary. How can I use the*Register syntax.

Thanks very much.
Deepak

0 Kudos
pvonkaenel
New Contributor III
456 Views
If you cannot guarantee the alignment of the source address, then I think you need to perform an unaligned load before calling the vector instructions. This adds a lot of overhead, so it would be best to make sure the source is properly aligned. Otherwise you can try performing unoptimized byte operations on the data up until you reach the alignment point you need andthen switch to the vector instructions..

Peter
0 Kudos
Reply