> The call fesetround could be any function in practice, and we never
> know if that function might use dynamic rounding mode floating point
> operation or not, also we don't know if it will be called fesetround
> or not.
> 
> So that's why we want to restore before function call to make sure we
> don't break rounding mode for any inner function, also backup the frm
> after function call can handle the case if the inner function has
> changed global rounding mode.

Ah, that clarifies things a bit.  Yes, I figured - the function is
opaque anyway.

I think we're touching a general question here, I suppose there already
have been discussions on the LLVM side about this?  What about ABI
implications?  By saving and restoring before and after a function
call we assume the FRM register to be call clobbered instead of
letting the function/call save/restore it.  Apart from fesetround
I can't imagine many cases where we would want to re-use the rounding
mode from inside a call so it might be advantageous to leave the
burden of saving/restoring to the callee.  But that's a similar
discussion as with the vector ABI so I don't expect a conclusion ;)

Regards
 Robin

Reply via email to