On Monday, 21 October 2019 at 20:12:19 UTC, Peter Jacobs wrote:
Toward the end of Walter's recent talk, D at 20, he says
something to the effect that optimizations are disabled when
exceptions can be thrown. We have a compressible flow solver
in which it is very convenient to be able to throw an exception
from deep within the code and catch it at a relatively high
level where we can partially recover and continue the
calculation. Because our calculations can run for days across
hundreds of processors, we also care about letting the
optimizer do its best. In what parts of our program would the
optimizer be disabled because of the presence of the exception
and its handling code? How do we tell?
It really comes into effect if you use:
a) structs with destructors
b) scope(exit) and scope(failure)
as these need to be run, regardless of the return mode of the
function i.e. normally or via an exception.
Also if the function is nothrow (possibly inferred because its a
template, n.b. also that nothrow function can throw Errors as
these are considered terminal) then you should also be fine. The
effect of exceptions on optimisation effect logic heavy code a
lot more that math heavy code.
What kind of conditions are you wanting to throw exception on?
infinities, NaNs, ill conditioning, something else?
As always the best way to check is to mark the function of
interest, nothrow take a look at the disassembly and compare to
without nothrow. You may also want to look to the optimisation
summary that I _think_ you can get LDC to generate.