Skip to main content
gamedev.net
🔒 Locked

Question about SSE2 integer arithmetic

Started by h3ro 1 reply 2.8k views
Original Post
h3ro
h3ro
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.
felisandria
felisandria
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

~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
h3ro
h3ro
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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.