2 ms·
You may have to specify a flag like "-C target-cpu=native" -- not all CPUs support popcnt, so LLVM can't generate it without knowing details about the target.
by panic 9y ago
You may have to specify a flag like "-C target-cpu=native" -- not all CPUs support popcnt, so LLVM can't generate it without knowing details about the target. I can't get the compiler on godbolt.org to generate it either way, though.
- tmccrmck 9y agoYou need "-C opt-level=3 -C target-cpu=native -C target-feature=+ssse3" I actually wrote about it last week: http://tmccrmck.github.io//post/rust-optimization-partii/ http://tmccrmck.github.io//post/rust-optimization-partii/
- krallja 9y agoThere's a little typo in your C implementation of popcount: you reference `x` when you probably meant `n`
- tmccrmck 9y agoThanks. I fixed it.
- burntsushi 9y agoYou can drop `-C target-feature=+ssse3` since `target-cpu=native` will cover that. The `-C opt-level=3` isn't necessary either, but if you drop that, it looks like there's a function that doesn't get inlined. However, even without opt-level=3, the popcnt instruction is still emitted.
- dom0 9y agoDoes Rust support FMV (function multi-versioning)?