implement log2 earlier in pipeline