I am looking at Rust to rewrite a C++ codebase and I would like to know how to disable loop unrolling/vectorizing and control unroll count as well. In Clang we would use:
#pragma clang loop unroll(disable)
#pragma clang loop unroll(disable) vectorize(disable)
#pragma clang loop unroll_count(2)
It is highly performance sensitive code and not having control over loop codegen could be a showstopper.
You cannot control how a given loop is/is not unrolled. It has been proposed, but no real progress has been made on considering such an RFC, much less accepting and implementing it.
If you are looking for very broad capabilities, you can pass -C llvm-args=...
to the compiler to influence LLVM. If there's a way to disable loop unrolling completely, that might do what you want.
Pragmatically, I'd encourage you to get a walking skeleton of your code in Rust and see if the performance is acceptable. My personal experience has shown that "general" Rust code is more performant because of
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With