Jump to content
  • Advertisement
Sign in to follow this  
h3ro

Question about SSE2 integer arithmetic

This topic is 3780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hallo, I am working on converting a part of my code into SSE2 Intrinsics, but I have wondering about something. Is it not possible to multiply/divide/shift when working with 16 chars at the time? I have found the following commands for addition and subtraction, but nothing for mult/div/shift. _mm_add_epi8 _mm_sub_epi8 From what I can find the arithmetic operations I need is available if you work with 8 16bit intergers, but then I am wasting half the space in each SSE register.

Share this post


Link to post
Share on other sites
Advertisement
I'm a little confused regarding the number of bits you're trying to use, as you specified 16 char at one point. So I'm just going to list the allowed multiplication and shift functions (afaik, SSE2 doesn't have integer division available, you're going to have to use multiplication with a shift).

_mm_mulhi_epi16 (8 signed 16 bit from a * 8 signed 16-bit from b, packs upper 16 bits of 8 signed 32 result)
_mm_mulhi_epu16 (same as above, but unsigned)
_mm_mullo_epi16 (signed or unsigned, 16 bit int a * 16 bit int b, packs lower 16 of 32 bit result)
_mm_mul_su32 (multiplies lower 32 bit int a * lower 32 bit int b, returns 64 bit result)
_mm_mul_epu32(same as above, but unsigned)

All the shifts are listed here, so I'm not going to type them:
http://math.nju.edu.cn/help/mathhpc/doc/intel/cc/mergedProjects/intref_cls/common/intref_sse2_int_shift.htm

Share this post


Link to post
Share on other sites
Hey, thanks for you reply.

What I ment is that I want to work with 16 8bit chars at the time. Sorry for not making it clear. But from your answare and from what I have found out myself, I am not sure its possible.

I know I can add/subtract them, but as there is no info about multiplication/division I assume its not possible to do so with 16 8bit chars at the same time.

Looks like I have to pad my data so I can work on 8 16bit chars instead, even though it means that can only work on half the data at the same time.

Thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!