News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Load all 1s into an SSE register

Started by HooKooDooKu, December 15, 2011, 07:11:37 PM

Previous topic - Next topic

HooKooDooKu

Any good tricks for quickly loading an SSE register with all 1s?

I'm currently doing it with the following three lines of code
      movq   xmm1, qwTRUE   ;Reload xmm6
      movq   xmm6, xmm1      ;   with
      movlhps xmm6, xmm1      ;   All 1s

where qwTRUE = 0xFFFFFFFFFFFFFFFF

Given that pxor can be used to clear a register, I was hoping there was some way to set all the bits in a register with only two lines

jj2007

Why don't you use an OWORD from memory?

include \masm32\MasmBasic\MasmBasic.inc   ; download
x1   OWORD -1
   Init
[/b]   movdqu xmm0, oword ptr x1
   Inkey Str$("xmm0=%i", xmm0)
   Exit
end start

xmm0=-1

If you want to use an older assembler like ml 6.15, use two qwords:
x1 dq -1, -1
...
movdqu xmm0, oword ptr x1

qWord

FPU in a trice: SmplMath
It's that simple!

jj2007

jj:qWord = 0:1  :green2

It's even a little bit faster:
Intel(R) Celeron(R) M CPU        420  @ 1.60GHz (SSE3)
208     cycles for 100*movdqa
142     cycles for 100*pcmpeqb

209     cycles for 100*movdqa
142     cycles for 100*pcmpeqb

HooKooDooKu

Well, for one, I've never heard of an OWORD  (I've done ASM before, but I had never used any of the MMX/SSE2 instructions before about two weeks ago).
Then, for two, my primary assembler (C++ with __asm blocks) doesn't know what an OWORD is.

However, it looks like my secondary assembler (MASM64) does, so I'll use that there if no one has a more universal solution.

HooKooDooKu

Thanks qWord. 
I had a feeling that for something so basic there would be a one line piece of code that would do that.


bomz

QuoteIntel(R) Pentium(R) 4 CPU 2.26GHz (SSE2)
88      cycles for movdqa
187     cycles for pcmpeqb

87      cycles for movdqa
187     cycles for pcmpeqb


--- ok ---