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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:33:40+00:00 2026-06-03T22:33:40+00:00

I want to write a c program which counts the number of bytes in

  • 0

I want to write a c program which counts the number of bytes in a range a…c with below code:

char a[16], b[16], c[16];  
int counter = 0; 
for(i = 0;  i < 16; i++)  
{  
  if((a[i] < b[i]) && (b[i] < c[i]))  
  counter++;  
}  
return counter;  

I am planning to do something like this

__m128i result1 = _mm_cmpgt_epi8 (b, a);  
__m128i result2 = _mm_cmplt_epi8 (b, c);  
unsigned short out1 = _mm_movemask_epi8(result1);  
unsigned short out2 = _mm_movemask_epi8(result2);  
unsigned short out3 = out1 & out2;  
unsigned short out4 = _mm_popcnt_u32(out3);   

Is my method correct? Is there is a better way to do this?

  • 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-03T22:33:41+00:00Added an answer on June 3, 2026 at 10:33 pm

    Your approach looks pretty reasonable. I think you could save an instruction by doing the AND inside the SIMD registers, like this:

    __m128i result1 = _mm_cmpgt_epi8 (b, a);
    __m128i result2 = _mm_cmplt_epi8 (b, c);
    __m128i mask = _mm_and_si128(result1, result2);
    int mask2 = _mm_movemask_epi8(mask);
    int counter = _mm_popcnt_u32(mask2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is a code which i want to write. int opt; po::options_description desc(Allowed options);
I want to write a program in which plays an audio file that reads
I want to write a simple program which shows my internet activity over a
I want to write a little program which is able to work with Google
suppose we have two numbers i want write program which print common bits subsequent
I want to write a program which downloads some data from Internet (PC part)
I am new to Swing. I want to write a program which reads a
I want to write an program which can find some metainformation of mediafile. I'm
I want to write a program which will print a string every second on
I want to write a simple program which can customize iphone icons like their

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.