[LLVMdev] llvm.sqrt and undefined behavior
Dan Gohman
djg at cray.com
Fri Aug 10 07:27:52 PDT 2007
In llvm.sqrt, why is the penalty for negative operands undefined behavior,
as opposed to merely an unspecified result?
As an example, in code like this:
%x = call float @llvm.sqrt.f32(float %y)
%z = fcmp oge float %y, -0.0
Does LLVM intend to reserve the right to assume that %z is always true?
Or that %z is undef? Or even that any statement dominated by %x is
unreachable?
There's the issue of side-effects that many floating-point operations
can have, such as errno, FP status flags, and signals, depending on the
target and various other details. LangRef currently has no mention of
any of those things anywhere though, so it seems there are implicit
blanket permissions for floating-point error behavior.
Dan
--
Dan Gohman, Cray Inc.
More information about the llvm-dev
mailing list