Passing -ffast-math along to llvm

It is possible in rust to somehow get -ffast-math passed to llvm?
This would tell LLVM that it is ok to vectorize floating point operations.

see:
http://llvm.org/docs/Vectorizers.html

In general it might be useful to have the ability to pass along all/most of the vectorizing options mentioned in there from rust.

2 Likes

-Cllvm-args=-ffast-math ?

I just use that as an argument on rustc? How to I apply it in a Cargo.toml? Sorry for the noob questions, I am a noob.

Doesn't look like that works.

If you're using cargo, you have to use cargo rustc

I'm not sure but after googling and experimenting furiousIy think that maybe there is no LLVM option to do this globally, that the floating point operations have to be tagged as 'fast' in the intermediate representation for this to happen. Which would mean the rust compiler would have to specifically support this. Which would be great if it did.

Yeah, ffast-math is a frontend (clang) type option. There's a few fast-math intrinsics you can experiment with. It doesn't always have the full vectorization effect (I have tried sum, which was fine, but dot product was open for manual improvements).

2 Likes

Oh that's great, I don't suppose there is any way to get the core library map/fold functions to use them though? Other than extending them with your own fastmap/fastfold etc?