Refactor reciprocal square root estimate into target-independent function; NFC.
authorSanjay Patel <spatel@rotateright.com>
Sun, 21 Sep 2014 15:19:15 +0000 (15:19 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sun, 21 Sep 2014 15:19:15 +0000 (15:19 +0000)
commit3e05b40fd083c4c5b1428ebd975616c0f0221388
tree5ad2c6043b254ab9946ff2f66c5a736f9fc25808
parent42dac6565f5e2d9ccd47d06a9edb714c1d51a200
Refactor reciprocal square root estimate into target-independent function; NFC.

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:

z = y / sqrt(x)

into:

z = y * rsqrte(x)

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

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.

Next steps:

    The code in DAGCombiner::BuildRSQRTE() should be refactored further; tests that exercise that logic need to be added.
    Logic in PPCTargetLowering::BuildRSQRTE() should be hoisted into DAGCombiner.
    X86 and AArch64 overrides for TargetLowering.BuildRSQRTE() should be added.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218219 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLowering.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/Target/PowerPC/PPCISelLowering.cpp
lib/Target/PowerPC/PPCISelLowering.h