Compiler option to list missed vectorization opportnunities

I'm pretty sure there is a cargo/compiler flat that will tell rustc to output which loops weren't vectorized and why. I just can't find it or remember what it is. Does anyone here know?

This seems like it would be handled by LLVM and not rustc proper, and indeed LLVM has -Rpass-missed=loop-vectorize (and -Rpass-analysis=loop-vectorize) which sounds like what you want. You can pass this to rustc with -C llvm-args='-Rpass-missed=loop-vectorize'.


rustc -C llvm-args='-Rpass-missed=loop-vectorize' src/ --crate-type lib
rustc rejects that as an unknown command line argument. I tried it with various combinations of the quotes too.

Oh, I guess rustc's interface to LLVM doesn't support passing the option in that form, oops. Looking at the output of rustc -C llvm-args=--help-list-hidden, you probably want -C llvm-args='--pass-remarks-missed=loop-vectorize', or the same with missed replaced by analysis.

1 Like

Thanks! I finally got it to work with:

cargo rustc --release -- -g -O -C llvm-args='--pass-remarks-missed=loop-vectorize'


For those reading this later,
cargo rustc --release -- -g -O -C llvm-args='--pass-remarks-analysis=loop-vectorize' is very nice because it tells you why the loop wasn't vectorized.

And rustc -C llvm-args=--help-list-hidden is FULL of other options. That's the way to help yourself!

1 Like