flat assembler
Message board for the users of flat assembler.

Index > Main > floating point cmp, bit twiddling expertise needed

Author
Thread Post new topic Reply to topic
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 01 Dec 2013, 11:54
We can determine if two 128-bit sse registers xmm0 and xmm1 have exactly the same bit pattern with
Code:
pcmpeqb xmm0,xmm1
pmovmskb  eax,xmm0
cmp  ax,-1    

but unfortunately this cannot be extended to 256 bits because vpcmpeqb is not supported on 256-bit operands in AVX.
Is it possible to get the same functionality in AVX by using the floating point operations? (The floating point ops are supported in AVX.)
Code:
vcmpeqpd ymm2,ymm0,ymm1
vmovmskpd  eax,ymm2
cmp  eax,01111b    

This doesn't work because 0x8000000000000000, and 0x0000000000000000 are treated as equal. Sad
Post 01 Dec 2013, 11:54
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 01 Dec 2013, 13:38
I don't have a processor with AVX to try this but maybe:
Code:
vptest ymm0,ymm1
j[c/z] ...    
Question
Post 01 Dec 2013, 13:38
View user's profile Send private message Reply with quote
tthsqe



Joined: 20 May 2009
Posts: 767
tthsqe 01 Dec 2013, 14:03
ah, this is very good! Thanks, cod3b453! I completely forgot about ptest.
Actually, I think the following are correct
Code:
; zero test
; if (ymm0=0), then a, else b
 vptest  ymm0,qqword[mask]
     jz  a
b:
a:

; another zero test
; if (ymm0=0), then a, else b
 vxorps  ymm1,ymm1,ymm1
 vptest  ymm1,ymm0
     jc  a
b:
a:

; equality test
; if (ymm0=ymm1), then a, else b
 vxorps  ymm2,ymm0,ymm1
 vptest  ymm2,qqword[mask]
     jz  a
b:
a:

align 32
mask: dq -1,-1,-1,-1    
Post 01 Dec 2013, 14:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.