[LLVMdev] llvm.sqrt intrinsic undefined behaviour

Tim Northover t.p.northover at gmail.com
Fri Nov 1 01:51:21 PDT 2013


> I strongly disagree with this proposal.  The purpose of this general
> purpose intrinsic is to expose sqrt functionality present on many of
> the architectures LLVM supports.  If we defined its edge cases, we
> won't be able to map it to target functionality freely on targets whose
> edge cases don't match that definition.

I agree the targets should be the primary focus, but a cursory search
failed to find one whose sqrt instruction(s) didn't produce NaN for
negative values; it's pretty much the only sane choice. Do they exist
(perhaps odd GPUs or something that always traps)?

If not, perhaps we could sensibly decouple the errno stuff from the
actual value produced: make no guarantees about what happens to the
environment but specify the result.

Cheers.

Tim.



More information about the llvm-dev mailing list