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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:09:51+00:00 2026-05-27T09:09:51+00:00

How would one create a mask using SSE intrinsics which indicates whether the signs

  • 0

How would one create a mask using SSE intrinsics which indicates whether the signs of two packed floats (__m128’s) are the same for example if comparing a and b where a is [1.0 -1.0 0.0 2.0] and b is [1.0 1.0 1.0 1.0] the desired mask we would get is [true false true true].

  • 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-05-27T09:09:52+00:00Added an answer on May 27, 2026 at 9:09 am

    Here’s one solution:

    const __m128i MASK = _mm_set1_epi32(0xffffffff);
    
    __m128 a = _mm_setr_ps(1,-1,0,2);
    __m128 b = _mm_setr_ps(1,1,1,1);
    
    __m128  f = _mm_xor_ps(a,b);
    __m128i i = _mm_castps_si128(f);
    
    i = _mm_srai_epi32(i,31);
    i = _mm_xor_si128(i,MASK);
    
    f = _mm_castsi128_ps(i);
    
    //  i = (0xffffffff, 0, 0xffffffff, 0xffffffff)
    //  f = (0xffffffff, 0, 0xffffffff, 0xffffffff)
    

    In this snippet, both i and f will have the same bitmask. I assume you want it in the __m128 type so I added the f = _mm_castsi128_ps(i); to convert it back from an __m128i.

    Note that this code is sensitive to the sign of the zero. So 0.0 and -0.0 will affect the results.


    Explanations:

    The way the code works is as follows:

    f = _mm_xor_ps(a,b);       //  xor the sign bits (well all the bits actually)
    
    i = _mm_castps_si128(f);   //  Convert it to an integer. There's no instruction here.
    
    i = _mm_srai_epi32(i,31);  //  Arithmetic shift that sign bit into all the bits.
    
    i = _mm_xor_si128(i,MASK); //  Invert all the bits
    
    f = _mm_castsi128_ps(i);   //  Convert back. Again, there's no instruction here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would one create a Singleton class using PHP5 classes?
Using Django's built in models, how would one create a triple-join between three models.
How would one create a custom MXML component in flex which is based on
How would one create a deterministic Javascript HTML colour picker which given arguments of
How would one create a REST web service to write a row into a
How would one typically create a dynamic factory method in PHP? By dynamic factory
I'd like to know how one would create an application that starts in the
I would like to create one EMF object and use it in various Resource
In Business Intelligence Developer Studio, I'm wondering why one would want to create a
I would like to create a spinning menu akin to the one done in

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.