Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:57:22+00:00 2026-06-02T17:57:22+00:00

Where does the x86-64’s SSE instructions (vector instructions) outperform the normal instructions. Because what

  • 0

Where does the x86-64’s SSE instructions (vector instructions) outperform the normal instructions. Because what I’m seeing is that the frequent loads and stores that are required for executing SSE instructions is nullifying any gain we have due to vector calculation. So could someone give me an example SSE code where it performs better than the normal code.

Its maybe because I am passing each parameter separately, like this…

__m128i a = _mm_set_epi32(pa[0], pa[1], pa[2], pa[3]);
__m128i b = _mm_set_epi32(pb[0], pb[1], pb[2], pb[3]);
__m128i res = _mm_add_epi32(a, b);

for( i = 0; i < 4; i++ )
 po[i] = res.m128i_i32[i];

Isn’t there a way I can pass all the 4 integers at one go, I mean pass the whole 128 bytes of pa at one go? And assign res.m128i_i32 to po at one go?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:57:25+00:00Added an answer on June 2, 2026 at 5:57 pm

    Summarizing comments into an answer:

    You have basically fallen into the same trap that catches most first-timers. Basically there are two problems in your example:

    1. You are misusing _mm_set_epi32().
    2. You have a very low computation/load-store ratio. (1 to 3 in your example)

    _mm_set_epi32() is a very expensive intrinsic. Although it’s convenient to use, it doesn’t compile to a single instruction. Some compilers (such as VS2010) can generate very poor performing code when using _mm_set_epi32().

    Instead, since you are loading contiguous blocks of memory, you should use _mm_load_si128(). That requires that the pointer is aligned to 16 bytes. If you can’t guarantee this alignment, you can use _mm_loadu_si128() – but with a performance penalty. Ideally, you should properly align your data so that don’t need to resort to using _mm_loadu_si128().


    The be truly efficient with SSE, you’ll also want to maximize your computation/load-store ratio. A target that I shoot for is 3 – 4 arithmetic instructions per memory-access. This is a fairly high ratio. Typically you have to refactor the code or redesign the algorithm to increase it. Combining passes over the data is a common approach.

    Loop unrolling is often necessary to maximize performance when you have large loop bodies with long dependency chains.


    Some examples of SO questions that successfully use SSE to achieve speedup.

    • C code loop performance (non-vectorized)
    • C code loop performance [continued] (vectorized)
    • How do I achieve the theoretical maximum of 4 FLOPs per cycle? (contrived example for achieving peak processor performance)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

x86 does not have an SSE instruction to convert from unsigned int32 to floating
What x86-64 instructions are used to enable/disable other cores/processors and how does one start
The vcvarsall.bat that does setup de build environment let you choose between x86 |
Does anyone know a good tool that would give me x86 instruction execution count.
How does a x86 disassembler know where to break up the instructions? I am
In x86 assembly, what does an h suffix on numbers represent? For example: sub
Does developing applications for SPARC , IBM PowerPC require separate compliers, other than x86
Does Erlang work on any non-x86 platforms? Microcontrollers for instance? I think it'd be
Since the ret instruction is an indirect call, does the ret instruction on x86
The code for x86 does this (n can only be 1 through 4, unknown

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.