https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466

--- Comment #15 from Daniel Elliott <cpphackster at gmail dot com> ---
Good catch johnathan on the return type of max. (PS also enjoyed your accu talk
on youtube).

I also have been messing around with the benchmark a bit and have come to the
conclusion that the sign function and the max isn't really necesary. simple
ternary operators seems to do a better job.

However, gcc still seems to be slower in these cases compared to clang.

Ive attached benchmarkv2 which on my ivy bridge 2013 macbook pro gets....

GCC:
ifStandard          600741 ns     600594 ns       1056
ifNoConditional     191043 ns     191000 ns       3694

Clang:
ifStandard           88777 ns      88726 ns       7439
ifNoConditional      89818 ns      89777 ns       7910

Interestingly for the gcc case, if I return float from the when_greater_than
function (which is just doing x > y ? 1: 0;  then it matches gcc ifStandard
speed exactly but if I return a float then goes down to the ~191000 ns speed
shown above. But still not as fast as both clang cases.  

Have to say this is a lot of fun and thanks everyone for looking at this!

Reply via email to