Using @fastmath(sqrt) as a way to get a square root calculation without the domain (x < 0) check is a bit of an abuse of the macro. Instead, there should be an unchecked_sqrt function that skips the domain check without also annotating code with fast-math flags since that can introduce unwanted semantics.
A constraint is that we don't want to break the genericness of the implementation, so a reasonable fallback path needs to be indentified. For instance, right now the method called is actually Base.FastMath.sqrt_fast which may already have useful overloads from other number-type packages that we don't necessarily want to lose. Therefore some research across the package ecosystem is probably warranted.
Using
@fastmath(sqrt)
as a way to get a square root calculation without the domain (x < 0) check is a bit of an abuse of the macro. Instead, there should be anunchecked_sqrt
function that skips the domain check without also annotating code with fast-math flags since that can introduce unwanted semantics.A constraint is that we don't want to break the genericness of the implementation, so a reasonable fallback path needs to be indentified. For instance, right now the method called is actually
Base.FastMath.sqrt_fast
which may already have useful overloads from other number-type packages that we don't necessarily want to lose. Therefore some research across the package ecosystem is probably warranted.More context in a Julia Discourse post and a related LLVM bug report