[PATCH] Refactor reciprocal square root estimate into target-independent function (part 1).

Sanjay Patel spatel at rotateright.com
Sat Sep 20 11:57:35 PDT 2014


Hi hfinkel, rengolin, chandlerc,

This is purely a plumbing patch. No functional changes intended.

The ultimate goal is to allow targets other than PowerPC (certainly X86 and Aarch64) to turn this:
   y = C / sqrt(x)
into:
   y = C * rsqrte(x)

using whatever HW magic they can use. See http://llvm.org/bugs/show_bug.cgi?id=20900 .

Currently, this is guarded by unsafe-fp-math, but I'm not sure if that's necessary in all cases.

The first step is to add a target hook for RSQRTE, take the already target-independent code selfishly hoarded by PPC, and put it into DAGCombiner. That's this patch.

Next steps:
1. The code in DAGCombiner::BuildRSQRTE() should be refactored further, but see note below.
2. Logic in PPCTargetLowering::BuildRSQRTE() should be hoisted into DAGCombiner.
3. X86 and AArch64 overrides for TargetLowering.BuildRSQRTE() should be added.

Note: when first creating this patch I accidentally wiped out the FP_EXTEND and FP_ROUND cases...and 'make check' still passed. The existing PPC tests in test/CodeGen/PowerPC/recipest.ll are inadequate. I didn't want to alter this code too much from the existing PPC version and risk screwing up some untested functionality.

http://reviews.llvm.org/D5425

Files:
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCISelLowering.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5425.13904.patch
Type: text/x-patch
Size: 8743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140920/79d3e6d5/attachment.bin>


More information about the llvm-commits mailing list