{"id":97335,"date":"2017-11-02T07:00:00","date_gmt":"2017-11-02T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=97335"},"modified":"2019-03-13T01:37:29","modified_gmt":"2019-03-13T08:37:29","slug":"20171102-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20171102-00\/?p=97335","title":{"rendered":"What are the dire consequences of accessing the fields of <CODE>__m128i<\/CODE> directly?"},"content":{"rendered":"<p><a HREF=\"https:\/\/docs.microsoft.com\/en-us\/cpp\/cpp\/m128i\">The MSDN documentation for <code>__m128i<\/code><\/a> says <\/p>\n<blockquote CLASS=\"q\"><p>You should not access the <b>__m128i<\/b> fields directly. <\/p><\/blockquote>\n<p>What are the dire consequences of <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20141208-00\/?p=43453\">accessing the fields directly<\/a>? <\/p>\n<p>The first consequence is portability: The contents of the <code>__m128i<\/code> structure are not standardized. It is a 16-byte value stored on a 16-byte boundary,  but that&#8217;s all that is required. If you go digging around inside it, you are tying yourself to a particular implementation&#8217;s definition of <code>__m128i<\/code>. <\/p>\n<p>The other consequence is performance: If a <code>__m128i<\/code> value is in an XMM register, and you try to access a field from it, the compiler will store the XMM register to memory, so that it can then extract the appropriate field. If you want to pull out specific fields, you are better-served using an intrinsic if an applicable one is available. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It works, but not well.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-97335","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It works, but not well.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=97335"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97335\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=97335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=97335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=97335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}