Revision 6642d883
Added by David Sorber over 10 years ago
| software/misc/bit_position/bit_position.c | ||
|---|---|---|
|
//~ 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)
|
||
| ... | ... | |
|
|
||
|
//~ printf("Index: %" PRIu32 "\n", idx);
|
||
|
|
||
|
uint64_t position = 0;
|
||
|
volatile uint64_t position = 0;
|
||
|
while (copy) {
|
||
|
position = __builtin_ctzll(copy);
|
||
|
//~ printf("%" PRIu64 " ", position);
|
||
| ... | ... | |
|
|
||
|
//~ printf("Index: %" PRIu32 "\n", idx);
|
||
|
|
||
|
uint64_t position = 0;
|
||
|
volatile uint64_t position = 0;
|
||
|
while (copy) {
|
||
|
position = __builtin_ctzll(copy);
|
||
|
//~ printf("%" PRIu64 " ", position);
|
||
| ... | ... | |
|
|
||
|
//~ printf("Index: %" PRIu32 "\n", idx);
|
||
|
|
||
|
uint64_t position = 0;
|
||
|
volatile uint64_t position = 0;
|
||
|
while (vector) {
|
||
|
position = __builtin_ffsll(vector);
|
||
|
//~ printf("%" PRIu64 " ", position);
|
||
Correctly my example code by declaring position volatile in each approach function. Without this modification loads and stores to position get optimized out.