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 8896605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:06:48+00:00 2026-06-15T00:06:48+00:00

I’m in the process of optimizing my code using SSE3. There’s one point in

  • 0

I’m in the process of optimizing my code using SSE3. There’s one point in the code that is forcing me to shift all of the elements in an vector by one element

v[0] = 0   //v is some char* and N = v.size()
for(int i = 1;i<N;i++){
    v[i] = v[i-1];
}

As far as I can tell, SSE doesn’t support vector shifting, so I’ll have to code this one from scratch.

But then I had the idea, what if I just decrement the pointer.

v = (v-1); 
v[0] = 0;

In this way, the operation will be constant won’t require any operations at all.

I’ve already tested this and it works for my test program.
However, I’m not sure that this operation is safe.

Is this a really dumb idea?

  • 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-15T00:06:49+00:00Added an answer on June 15, 2026 at 12:06 am

    SSE does support shifting, either bitwise shifting of the elements inside a vector and shifting of whole registers along byte boundaries too.

    Assuming your vector is of type 16 times uint8_t, the operation you are looking for is

    psrldq xmm, 1      ;packed shift right logical double quad word
    

    with the intrinsic

    vec = _mm_srli_si128(vec, 1);   // shift by 1 byte
    

    To your first question: As long as v is a pointer to char, decrementing or incrementing it is completely safe. Dereferencing may not, that depends on your program.

    To your second question: Yes, it looks like a dumb idea. If you try to optimize with SSE and you perform some tasks with pointers to bytes you are most likely doing something wrong, and you are calling for trouble if you try to load 16 of your v into a SSE register – either segfaults because of misalignment or a performance penalty because of forcing the compiler to use movdqu.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace

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.