4 ms·
Thanks, I didn't know about this. Interesting that it seems to require fast-math.
by camel-cdr 2y ago
Thanks, I didn't know about this. Interesting that it seems to require fast-math.
- ComputerGuru 2y agoThat means it’ll never be used. ffast-math is verboten in most serious codebases.
- dzaima 2y agoSeems "-fno-math-errno" is enough for clang. gcc needs a whole "-fno-math-errno -funsafe-math-optimizations -ffinite-math-only".
- Avamander 2y agoSo is the optimization "wrong" or "unsafe" even in the case of Intel's ICX compiler? Is it that you can't express the right (error) semantics in C? I'm just wondering why those two require the flag and the other doesn't.
- dzaima 2y agoICX appears to just default to fast-math: https://godbolt.org/z/jzPazGjoh https://godbolt.org/z/jzPazGjoh Requiring -fno-math-errno is sane enough, essentially noone needs math errno anyway (and that flag is needed to vectorize even sqrt, for which there's a proper full hardware SIMD instruction, but which obviously doesn't set errno on a negative input or whatever). Probably depends on the vector math library used whether it handles near-infinity or inf/NaN values properly. And there's also the potential concern that the scalar and vector exp() likely give different results, leading to weird behavior, which might be justification for -funsafe-math-optimizations.