- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm testing a custom implementation of strcmp() which involves SSE4.2 and this instruction in particular:
pcmpistri $0x18,(%rsi,%rax,1),%xmm1
I've made a test that passes unaligned pointers to the custom strcmp(), the test looks like this:
#include <string.h> const char a[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; const char b[] = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; int main() { return strcmp(a + 1, b + 1); }
I verified in the debugger that the pointers are actually not 16-byte aligned when the above instruction is executed. My expectation was that the instruction would crash, however it did not. In fact, the function works correctly, i.e. returns 0.
My question is, does pcmpistri not actually require the memory operand to be aligned? I looked in "Intel(R) 64 and IA-32 Architectures Software Developer Manual" and the instruction is documented as having an m128 operand, which is, as I understand, required to be aligned.
I'm running on a Sandy Bridge CPU.
- Tags:
- Intel® Advanced Vector Extensions (Intel® AVX)
- Intel® Streaming SIMD Extensions
- Parallel Computing
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The STTNI instructions (SSE4.2) do not have the usual SSE 16B alignment requirements. This is listed in the "Other Exceptions" section of volume 2 for each of these instructions. There is a footnote in section 2.4.4 of rev 54 of volume 2 (pdf page 59) of the Intel SDM. http://www.intel.com/sdm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah, I was reading an outdated version of the document that didn't have that footnote. Thanks, Mark.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page