[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 11:55:17 PST 2017
jlebar added a comment.
In https://reviews.llvm.org/D28797#648535, @efriedma wrote:
> This is false: we take advantage of this to lower @llvm.sqrt() to libm sqrt() on platforms which don't have a native sqrt instruction, and that can have side-effects. See also https://reviews.llvm.org/D28335 .
We can lower it to `if (x >= -0) libm_sqrt(x) else NaN`? It's already broken per Sanjoy's comment.
I would like to make this langref change because I want to convert the opaque target-specific `llvm.nvvm.sqrt.f` intrinsic to something involving `llvm.sqrt.f32` (so that all of our sqrt-optimization machinery can be brought to bear).
More information about the llvm-commits