Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


You 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/


You 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.


There's a little typo in your C implementation of popcount: you reference `x` when you probably meant `n`


Thanks. I fixed it.


Does Rust support FMV (function multi-versioning)?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: