Hacker News new | ask | show | jobs
by munificent 1366 days ago
I strongly suspect that in most cases, yes, you do. The only time you wouldn't pay this cost is if the multiplication outside of the sin() call and the multiplication inside of it can be constant folded together. That requires the call to sin() to have its code inlined at the callsite. Given how large most sin() implementations are, I would be fairly surprised if it does get inlined.

The only way to answer this is to profile it and see.

1 comments

Even if it was inlined, I don't think compiler is allowed to rearrange floating-point calculations without -ffast-math or other scary flags.