diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-02-06 05:43:00 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-02-06 05:43:00 +0000 |
commit | 79c25649b740ad2ac1dce80b5303b2b98470495c (patch) | |
tree | f560ea2c3067ba780eac085a0890b035bfe42afe /apps | |
parent | a7738a352641d2697e1cccb21342ec901485200c (diff) | |
download | rockbox-79c25649b740ad2ac1dce80b5303b2b98470495c.tar.gz rockbox-79c25649b740ad2ac1dce80b5303b2b98470495c.zip |
use a table-free clz on coldfire, where it benchmarks a bit faster
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19933 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/pictureflow.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index cd7e54ce35..0e48a64e2d 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c | |||
@@ -346,11 +346,50 @@ static inline int clz(uint32_t v) | |||
346 | } | 346 | } |
347 | 347 | ||
348 | /* Otherwise, use our clz, which can be inlined */ | 348 | /* Otherwise, use our clz, which can be inlined */ |
349 | #elif defined(CPU_COLDFIRE) | ||
350 | /* This clz is based on the log2(n) implementation at | ||
351 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog | ||
352 | * A clz benchmark plugin showed this to be about 14% faster on coldfire | ||
353 | * than the LUT-based version. | ||
354 | */ | ||
355 | static inline int clz(uint32_t v) | ||
356 | { | ||
357 | int r = 32; | ||
358 | if (v >= 0x10000) | ||
359 | { | ||
360 | v >>= 16; | ||
361 | r -= 16; | ||
362 | } | ||
363 | if (v & 0xff00) | ||
364 | { | ||
365 | v >>= 8; | ||
366 | r -= 8; | ||
367 | } | ||
368 | if (v & 0xf0) | ||
369 | { | ||
370 | v >>= 4; | ||
371 | r -= 4; | ||
372 | } | ||
373 | if (v & 0xc) | ||
374 | { | ||
375 | v >>= 2; | ||
376 | r -= 2; | ||
377 | } | ||
378 | if (v & 2) | ||
379 | { | ||
380 | v >>= 1; | ||
381 | r -= 1; | ||
382 | } | ||
383 | r -= v; | ||
384 | return r; | ||
385 | } | ||
349 | #else | 386 | #else |
350 | static const char clz_lut[16] = { 4, 3, 2, 2, 1, 1, 1, 1, | 387 | static const char clz_lut[16] = { 4, 3, 2, 2, 1, 1, 1, 1, |
351 | 0, 0, 0, 0, 0, 0, 0, 0 }; | 388 | 0, 0, 0, 0, 0, 0, 0, 0 }; |
352 | /* This clz is based on the log2(n) implementation at | 389 | /* This clz is based on the log2(n) implementation at |
353 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup | 390 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup |
391 | * It is not any faster than the one above, but trades 16B in the lookup table | ||
392 | * for a savings of 12B per each inlined call. | ||
354 | */ | 393 | */ |
355 | static inline int clz(uint32_t v) | 394 | static inline int clz(uint32_t v) |
356 | { | 395 | { |