> Your suggested code seems work fine, let me run more test and send
> v2, I guess I just don’t know how to explain why it work in comment
> :p

If it's too convoluted maybe we should rather not use it :D

The idea is for
  factor % (vlenb / potential_div) == 0
we're actually looking for the largest power of 2 that factor
and vlenb are both a multiple of.

(Individually) for factor the largest pow2 can be calculated
by ctz (factor).  Same for vlenb via ctz (vlenb).

If ctz (factor) >= ctz (vlenb), vlenb already divides factor
evenly.

Otherwise, i.e. when ctz (factor) = 1 (divisible by 2) and
ctz (vlenb) = 4 (divisible by 16) we need to divide vlenb by the
pow2 difference 1 << (4 - 1).

I just realize that the explanation is longer than the code before,
maybe not a good sign ;)  

Regards
 Robin

Reply via email to