[Bug c++/85466] New: Performance is slow when doing 'branchless' conditional style math operations

2018-04-19 Thread cpphackster at gmail dot com
Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: cpphackster at gmail dot com Target Milestone: --- I have been investigating turning if statements into math operations inspired by a blog articl

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-19 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #14 from Daniel Elliott --- I had a response from chandler carruth on twitter, who informed me that the benchark was hoisting the computation out of the loop. So thats why clang was faster. but also he said that the noconditional vers

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-20 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #15 from Daniel Elliott --- 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

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-20 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #16 from Daniel Elliott --- Created attachment 44001 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44001&action=edit revised benchmark w/different approach

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-20 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #17 from Daniel Elliott --- my previous comment above meant to say this (change from float to int) 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

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-20 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #20 from Daniel Elliott --- cool. just tried that. gets gcc down to GCC: --- ifStandard 596892 ns ifNoConditional 148075 ns <--- with "result[n] = tab[item > .

[Bug libstdc++/85466] Performance is slow when doing 'branchless' conditional style math operations

2018-04-21 Thread cpphackster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85466 --- Comment #22 from Daniel Elliott --- (In reply to Marc Glisse from comment #21) > (In reply to Daniel Elliott from comment #20) > > still clang is 1.64x faster. had a look at the assembly. My limited > > understanding makes me think that the u