On quinta-feira, 12 de outubro de 2017 10:06:05 PDT Thiago Macieira wrote: > The conversion to double via ldexp is what generateDouble() does in the new > class and is optional. Though I will take a look now to see if using ldexp() > produces better code than > > return double(generate64()) / (double((std::numeric_limits<quint64>::max)()) > + 1);
Ok, quick test shows that using ldexp causes all 4 compilers tested (GCC 7, Clang 4, MSVC 2017 and ICC 17) to generate an out-of-line call to ldexp. My original code above is better, since it's all inline. See: https://godbolt.org/g/AS8XPC Yet my code is not optimal, since it generates a check for the sign bit because the x86 instruction CVTSI2SD takes a signed integer as input. That's useless, since the result has only 53 bits of randomness anyway. So a simple one-line masking the high bits change makes the result drop the branch in three of the four compilers (the one with the poor optimiser doesn't realise that masking the sign bit means the result can't have the sign bit set). See https://godbolt.org/g/m8WwXX -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development