forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fastest way to test quadword equality on SPU?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development
View previous topic :: View next topic  
Author Message
kroe



Joined: 02 Apr 2007
Posts: 6

PostPosted: Fri Jul 27, 2007 2:32 pm    Post subject: Fastest way to test quadword equality on SPU? Reply with quote

I may be overlooking something really obvios, but I can't find a good way to test equality of two quadwords.

I have two vector unsigned chars and I need to stop iterating when they are equal. The "==" comparator doesn't work with quadwords, and the spu_cmpeq intrinsic would require other subsequent operations to check the result of the equality test.

What is the best way to compare two quadwords for equality?

Thanks,
-Ken
Back to top
View user's profile Send private message
Mihawk



Joined: 03 Apr 2007
Posts: 29

PostPosted: Fri Jul 27, 2007 5:00 pm    Post subject: Reply with quote

If you're looking for a method without "other subsequent operations", then I believe there is none.

But this should be the shortest way I think:
Code:

ceq   $5, $3, $4   # compare words
gb   $6, $5      # gather bits from words
ceqi   $7, $6, 15
# then branch or selb

or something like that (didn't test).
Back to top
View user's profile Send private message
emoon



Joined: 18 Jan 2004
Posts: 91
Location: Stockholm, Sweden

PostPosted: Sat Jul 28, 2007 12:58 am    Post subject: Reply with quote

Maybe something like this (untested)

Code:

inline bool spu_all_eq(vector unsigned int a, vector unsigned int b)
{
    return((spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xf));
}
Back to top
View user's profile Send private message Visit poster's website
pheon



Joined: 31 Aug 2007
Posts: 1
Location: the concrete jungle

PostPosted: Fri Aug 31, 2007 3:23 pm    Post subject: Reply with quote

or maybe

xor r1, r2, r3
orx r1, r1
brz / brnz
Back to top
View user's profile Send private message
Warren



Joined: 24 Jan 2004
Posts: 173
Location: San Diego, CA

PostPosted: Mon Sep 03, 2007 9:39 pm    Post subject: Reply with quote

emoon wrote:
Maybe something like this (untested)

Code:

inline bool spu_all_eq(vector unsigned int a, vector unsigned int b)
{
    return((spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xf));
}


spu_extract et al are somewhat slow routines and should be avoided if possible.
Back to top
View user's profile Send private message
unsolo



Joined: 16 Apr 2007
Posts: 155
Location: OSLO Norway

PostPosted: Sun Nov 04, 2007 10:38 am    Post subject: Reply with quote

result=spu_gather(spu_cmpeq(A,B)))

if any B is equal to A then you will have a value in the element 0 of result
_________________
Don't do it alone.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group