diff --git a/projects/rocr-runtime/rocrtst/common/helper_funcs.cc b/projects/rocr-runtime/rocrtst/common/helper_funcs.cc old mode 100755 new mode 100644 index f145ffe49e..5b421029d3 --- a/projects/rocr-runtime/rocrtst/common/helper_funcs.cc +++ b/projects/rocr-runtime/rocrtst/common/helper_funcs.cc @@ -103,16 +103,15 @@ int FillRandom(T* arrayPtr, } uint64_t RoundToPowerOf2(uint64_t val) { - int bytes = sizeof(uint64_t); - val--; - - for (int i = 0; i < bytes; i++) { - val |= val >> (1 << i); - } + /* + * Shift with amount larger than the bit width can result in + * undefined behavior by compiler for release builds. + * Shift till 32 bit only which is less than bit width of val. + */ + for (int i = 1; i <= 32; i *= 2) val |= val >> i; val++; - return val; }