Performance improvement using pow2 dynamically cached implementation