[PATCH] D28797: [LangRef] Make @llvm.sqrt(x) return undef, rather than have UB, for negative x.
Justin Lebar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 14:43:01 PST 2017
jlebar added a comment.
In https://reviews.llvm.org/D28797#648865, @efriedma wrote:
> > On a mostly unrelated note, making llvm.sqrt() return undef rather than NaN for negative numbers is completely useless; we might as well just say that @llvm.sqrt is precisely the IEEE 754 squareRoot() operation minus any side-effects. We can mark a call "nnan" to indicate that the backend doesn't need to worry about negative numbers and nans.
> No response to this?
Discussed on IRC with Hal, he convinced me to try to make LLVM think that llvm.sqrt returns NaN for negative inputs, and then of course we can update the langref as you suggest.
No promises I'll be able to make it work. And with the changes I plan, we will continue to have the problem of legalizing llvm.sqrt to libm_sqrt, incorrectly adding side-effects to the function call, as we do for most of the other intrinsics.
More information about the llvm-commits