Hacker News new | past | comments | ask | show | jobs | submit login

gcc and clang are also capable of it, given certain compiler flags: https://godbolt.org/z/z766hc64n



Thanks, I didn't know about this. Interesting that it seems to require fast-math.


That means it’ll never be used. ffast-math is verboten in most serious codebases.


Seems "-fno-math-errno" is enough for clang. gcc needs a whole "-fno-math-errno -funsafe-math-optimizations -ffinite-math-only".


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


ICX appears to just default to fast-math: 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: