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
Fastest way to test quadword equality on SPU?
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:
or something like that (didn't test).
But this should be the shortest way I think:
Code: Select all
ceq $5, $3, $4 # compare words
gb $6, $5 # gather bits from words
ceqi $7, $6, 15
# then branch or selb
Maybe something like this (untested)
Code: Select all
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.emoon wrote:Maybe something like this (untested)
Code: Select all
inline bool spu_all_eq(vector unsigned int a, vector unsigned int b) { return((spu_extract(spu_gather(spu_cmpeq(a, b)), 0) == 0xf)); }