commit 6642d8832b7a34c0e56a2aef00e9f740c2cf2cf5
Author: David Sorber <david.sorber@gmail.com>
Date:   Fri Oct 30 07:08:54 2015 -0400

    Correctly my example code by declaring position volatile in each approach function.  Without this modification loads and stores to position get optimized out.

diff --git a/software/misc/bit_position/bit_position.c b/software/misc/bit_position/bit_position.c
index 6d3adc8..4ef2c1c 100644
--- a/software/misc/bit_position/bit_position.c
+++ b/software/misc/bit_position/bit_position.c
@@ -43,7 +43,7 @@ void approach0(uint32_t count, uint64_t* vectors)
         //~ printf("Index: %" PRIu32 "\n", idx);
         
         uint64_t compare = 1;
-        uint64_t position = 0;    
+        volatile uint64_t position = 0;    
         for (uint32_t ctr = 0; ctr < 64; ctr++)
         {
             if (compare & copy)
@@ -67,7 +67,7 @@ void approach1(uint32_t count, uint64_t* vectors)
         
         //~ printf("Index: %" PRIu32 "\n", idx);
         
-        uint64_t position = 0;
+        volatile uint64_t position = 0;
         while (copy) {
             position = __builtin_ctzll(copy);
             //~ printf("%" PRIu64 " ", position);
@@ -152,7 +152,7 @@ void approach2(uint32_t count, uint64_t* vectors)
         
         //~ printf("Index: %" PRIu32 "\n", idx);
         
-        uint64_t position = 0;
+        volatile uint64_t position = 0;
         while (copy) {
             position = __builtin_ctzll(copy);
             //~ printf("%" PRIu64 " ", position);
@@ -172,7 +172,7 @@ void approach3(uint32_t count, uint64_t* vectors)
         
         //~ printf("Index: %" PRIu32 "\n", idx);
         
-        uint64_t position = 0;
+        volatile uint64_t position = 0;
         while (vector) {
             position = __builtin_ffsll(vector);
             //~ printf("%" PRIu64 " ", position);
