f



How to shift Left or Right in SSE2

How do I do a bitwise shift left or right in SSE2?

I would like that each of the 4 Word is shifted left (or right) by  a
number of n bits.

I could only find _mm_srai_epi32  (only right!), which howevere does
not do what I want, as it brings in introduce the sign bit.

Thanks,
Fabio

0
spamtrap2 (1627)
2/5/2007 1:46:57 AM
comp.lang.asm.x86 5035 articles. 0 followers. Post Follow

3 Replies
1139 Views

Similar Articles

[PageSpeed] 47

spamtrap@crayne.org writes:

> How do I do a bitwise shift left or right in SSE2?
> 
> I would like that each of the 4 Word is shifted left (or right) by  a
> number of n bits.
> 
> I could only find _mm_srai_epi32  (only right!), which howevere does
> not do what I want, as it brings in introduce the sign bit.

pslldq followed by andpd.

Phil
-- 
"Home taping is killing big business profits. We left this side blank 
so you can help." -- Dead Kennedys, written upon the B-side of tapes of
/In God We Trust, Inc./.

0
Phil
2/5/2007 10:00:43 AM
On 5 Feb, 10:00, Phil Carmody <thefatphil_demun...@yahoo.co.uk> wrote:
> spamt...@crayne.org writes:
> > How do I do a bitwise shift left or right in SSE2?
>
Thanks.

However my undertanding is that pslldq is a byte-wise shift, not bit
wise shift. I.e. I can shift by 8 bits, 16 bits, 24 bits, etc..., but
not by 3 bits, for instance. Or is there a way around it?

Thanks.

Regards.
Fabio

> > I would like that each of the 4 Word is shifted left (or right) by  a
> > number of n bits.
>
> > I could only find _mm_srai_epi32  (only right!), which howevere does
> > not do what I want, as it brings in introduce the sign bit.
>
> pslldq followed by andpd.
>
> Phil
> --
> "Home taping is killing big business profits. We left this side blank
> so you can help." -- Dead Kennedys, written upon the B-side of tapes of
> /In God We Trust, Inc./.

0
spamtrap
2/6/2007 7:49:08 PM
On 6 Feb., 20:49, spamt...@crayne.org wrote:
> On 5 Feb, 10:00, Phil Carmody <thefatphil_demun...@yahoo.co.uk> wrote:> spamt...@crayne.org writes:
> > > How do I do a bitwise shift left or right in SSE2?
>
> Thanks.
>
> However my undertanding is that pslldq is a byte-wise shift, not bit
> wise shift. I.e. I can shift by 8 bits, 16 bits, 24 bits, etc..., but
> not by 3 bits, for instance. Or is there a way around it?
>
> Thanks.
>
> Regards.
> Fabio
>

If you want to shift every word in a xmm register you can use psllw.

intel tech docs:
PSLLW xmm1, imm8
(Shift words in xmm1 left by
imm8 while shifting in 0s.)

PSLLW instruction with 128-bit operand:
  IF (COUNT > 15)
  THEN
    DEST[128:0] ← 00000000000000000000000000000000H;
  ELSE
    DEST[15:0] ← ZeroExtend(DEST[15:0] << COUNT);
    (* Repeat shift operation for 2nd through 7th words *)
    DEST[127:112] ← ZeroExtend(DEST[127:112] << COUNT);
  FI;

It also works with dword(pslld) and qword(psllq), but there is no way
to bitwise shift the whole register.

greets,
Alan


0
Alan
2/8/2007 11:33:32 PM
Reply: