[PATCH] D29375: [TLI] Rework interface for approximate (r)sqrt and reciprocal.

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 22:21:12 PST 2017


jlebar created this revision.
Herald added subscribers: igorb, nhaehnle, nemanjai, arsenm, jholewinski.
Herald added a reviewer: tstellarAMD.

Previously this had a major limitation: The interface expected the
return value of getSqrtEstimate to be a reciprocal sqrt (even if
!Reciprocal).

Not only was this confusing, but it meant that platforms like NVPTX that
have an approximate sqrt had no way to use hook it in.

This patch reworks the API to separate out three questions which
previously were all squished into getSqrtEstimate:

- Should we do an estimate at all?
- If so, how many iterations of Newton's method should we perform to refine our estimate?
- What's our first approximation of the rsqrt?

Now we have one function which answers the first two questions, and a
separate function which answers the third.

We also now have a separate function which we call in the special case
when we're doing zero iterations of Newton's method and calculating a
plain sqrt, and NVPTX hooks into this.

We made the same changes to the reciprocal estimate functions.

In addition, we reworked the parsing of the reciprocal-estimates
metadata flag, which needed some love, and otherwise wasn't compatible
with this new scheme.


https://reviews.llvm.org/D29375

Files:
  llvm/include/llvm/Target/TargetLowering.h
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.h
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29375.86579.patch
Type: text/x-patch
Size: 52113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170201/30e366e4/attachment.bin>


More information about the llvm-commits mailing list