]> granicus.if.org Git - llvm/commit
[NVPTX] Compute approx sqrt as 1/rsqrt(x) rather than x*rsqrt(x).
authorJustin Lebar <jlebar@google.com>
Tue, 31 Jan 2017 23:08:57 +0000 (23:08 +0000)
committerJustin Lebar <jlebar@google.com>
Tue, 31 Jan 2017 23:08:57 +0000 (23:08 +0000)
commit6f09ea3f571cd2f4c39fff52deecec7cfc62d0c4
tree235c9d4ca67913b3a77c113a4bdfd30648a3e8bf
parentd99a5ea737c696917819bd764e5ecb960e15d0eb
[NVPTX] Compute approx sqrt as 1/rsqrt(x) rather than x*rsqrt(x).

x*rsqrt(x) returns NaN for x == 0, whereas 1/rsqrt(x) returns 0, as
desired.

Verified that the particular nvptx approximate instructions here do in
fact return 0 for x = 0.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293713 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/NVPTX/NVPTXISelLowering.cpp
test/CodeGen/NVPTX/fast-math.ll
test/CodeGen/NVPTX/sqrt-approx.ll