Refactor reciprocal and reciprocal square root estimate into target-independent functions (part 2).

This is purely refactoring. No functional changes intended. PowerPC is the only target
that is currently using this interface.

The ultimate goal is to allow targets other than PowerPC (certainly X86 and Aarch64) to turn this:

z = y / sqrt(x)

into:

z = y * rsqrte(x)

And:

z = y / x

into:

z = y * rcpe(x)

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

There is one hook in TargetLowering to get the target-specific opcode for an estimate instruction
along with the number of refinement steps needed to make the estimate usable.

Differential Revision: http://reviews.llvm.org/D5484



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218553 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sanjay Patel
2014-09-26 23:01:47 +00:00
parent 173573736b
commit 676af35b38
5 changed files with 214 additions and 240 deletions

View File

@@ -2624,10 +2624,21 @@ public:
return SDValue();
}
virtual SDValue BuildRSQRTE(SDValue Op, DAGCombinerInfo &DCI) const {
/// Hooks for building estimates in place of, for example, slower divisions
/// and square roots. These are not builder functions themselves, just the
/// target-specific variables needed for building the estimate algorithm.
/// Return an estimate value for the input opcode and input operand.
/// The RefinementSteps output is the number of refinement iterations
/// required to generate a sufficient (though not necessarily IEEE-754
/// compliant) estimate for the value type.
/// An empty SDValue return means no estimate sequence can be created.
virtual SDValue getEstimate(unsigned Opcode, SDValue Operand,
DAGCombinerInfo &DCI,
unsigned &RefinementSteps) const {
return SDValue();
}
//===--------------------------------------------------------------------===//
// Legalization utility functions
//