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:
- The code in DAGCombiner::BuildRSQRTE() should be refactored further, but see note below.
- Logic in PPCTargetLowering::BuildRSQRTE() should be hoisted into DAGCombiner.
- 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.