From 40cb5f6104f1531947b12787c1b29672588ef1f9 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Sun, 24 Oct 2010 05:59:10 +0000 Subject: Move variable declarations into loop git-svn-id: svn://mattst88.com/svn/alpha_mmintrin/trunk@8 f7d56953-e76f-4e43-a77e-20d50f6c004e --- testsuite/ctlz.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/testsuite/ctlz.c b/testsuite/ctlz.c index eb7c96b..81023f9 100644 --- a/testsuite/ctlz.c +++ b/testsuite/ctlz.c @@ -11,12 +11,11 @@ int main(int argc, char ** argv) { uint64_t a[ARRAY_ELEMENTS], b[ARRAY_ELEMENTS], c[ARRAY_ELEMENTS]; - uint64_t l1, l2; struct timespec cix_start, cix_end; double cix_t0, cix_t1, cix_total; struct timespec noncix_start, noncix_end; double noncix_t0, noncix_t1, noncix_total; - int i, j, count = 0; + int i, j; srand(time(NULL)); @@ -27,9 +26,8 @@ int main(int argc, char ** argv) { clock_gettime(CLOCK_MONOTONIC, &cix_start); for (j = 0; j < ITERATIONS; j++) { for (i = 0; i < ARRAY_ELEMENTS; i++) { - l1 = a[i]; - - l2 = 1 << (64 - __ctlz(l1)); + uint64_t l1 = a[i]; + uint64_t l2 = 1 << (64 - __ctlz(l1)); b[i] = l2; } @@ -39,14 +37,15 @@ int main(int argc, char ** argv) { clock_gettime(CLOCK_MONOTONIC, &noncix_start); for (j = 0; j < ITERATIONS; j++) { for (i = 0; i < ARRAY_ELEMENTS; i++) { - l1 = a[i]; + uint64_t l1 = a[i]; + uint64_t l2; + int count = 0; while (l1 != 0) { l1 >>= 1; count += 1; } l2 = 1 << count; c[i] = l2; - count = 0; } } clock_gettime(CLOCK_MONOTONIC, &noncix_end); -- cgit v1.2.3