Ciao, Il Mer, 30 Maggio 2018 10:20 am, Niels Möller ha scritto: > "Marco Bodrato" <bodr...@mail.dm.unipi.it> writes:
> Thinking about micro optimizations... Consider >> count_trailing_zeros (c, ulimb); >> ulimb = (ulimb >> 1) >> c; > vs >> count_trailing_zeros (c, ulimb); >> ulimb >>= (c + 1); > I wonder if maybe it's preferable to always use the first variant? Both You are saying that my patch https://gmplib.org/repo/gmp/rev/e4849ae7c974 was not an emergency workaround, but a cleverly subtle optimization? Well, I have to admit that I was not aware... but thanks :-) > first variant, the first shift can be issued in parallel with ctz, If we could hint to the compiler... HINT (c >= 0 && c + 1 < ....) then they should be equivalent. The optimiser of the compiler can choose the best one for the target environment :-) If we define c as unsigned, we do not need other hints, the compiler has enough information to understand that ulimb>>(c+1) can be implemented as (ulimb>>1)>>c for all non-undefined cases. The vice-versa is not as easy. Maybe, of course, that current compilers does not take care of this possible optimisation... Ĝis, m -- http://bodrato.it/ _______________________________________________ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs