Passing -ffast-math along to llvm


#1

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

-Cllvm-args=-ffast-math ?


#3

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.


#4

Doesn’t look like that works.


#5

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


#6

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.


#7

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


#8

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?