5 ms·
GCC turns a fold over a parameter pack into test/sete and turns std::min == 0 into cmp/cmovg: https://godbolt.org/z/TjK7Gz74M https://godbolt.org/z/TjK7Gz74M
by thestoicattack 4y ago
GCC turns a fold over a parameter pack into test/sete and turns std::min == 0 into cmp/cmovg: https://godbolt.org/z/TjK7Gz74M https://godbolt.org/z/TjK7Gz74M
- leni536 4y agollvm-mca prefers the "fold" over the "min". Intuitively it's more pipelinable. The codegen for "min" has data dependencies that are not there for the "fold" version. https://godbolt.org/z/1zjKP6z8q https://godbolt.org/z/1zjKP6z8q edit: A mixture of the two approaches possibly outperforms both: https://godbolt.org/z/WxGWPvYTs https://godbolt.org/z/WxGWPvYTs edit2: Doh, of course to be be correct for the min approach, you need to use unsigned. Does not change the performance though.
- deleted 4y ago[deleted]