| View previous topic :: View next topic |
| Author |
Message |
kroe
Joined: 02 Apr 2007 Posts: 6
|
Posted: Fri Jul 27, 2007 2:32 pm Post subject: Fastest way to test quadword equality on SPU? |
|
|
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 |
|
 |
Mihawk
Joined: 03 Apr 2007 Posts: 29
|
Posted: Fri Jul 27, 2007 5:00 pm Post subject: |
|
|
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 |
|
 |
emoon

Joined: 18 Jan 2004 Posts: 91 Location: Stockholm, Sweden
|
Posted: Sat Jul 28, 2007 12:58 am Post subject: |
|
|
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 |
|
 |
pheon
Joined: 31 Aug 2007 Posts: 1 Location: the concrete jungle
|
Posted: Fri Aug 31, 2007 3:23 pm Post subject: |
|
|
or maybe
xor r1, r2, r3
orx r1, r1
brz / brnz |
|
| Back to top |
|
 |
Warren
Joined: 24 Jan 2004 Posts: 173 Location: San Diego, CA
|
Posted: Mon Sep 03, 2007 9:39 pm Post subject: |
|
|
| 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 |
|
 |
unsolo
Joined: 16 Apr 2007 Posts: 155 Location: OSLO Norway
|
Posted: Sun Nov 04, 2007 10:38 am Post subject: |
|
|
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 |
|
 |
|