[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 1 Oct 2019 15:32:04 +0000 (15:32 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Tue, 1 Oct 2019 15:32:04 +0000 (15:32 +0000)
commit3c912c4abe2bb962c7bddcf52fab6c65bc5899d5
treefd5dff7bf60f5cb602ab16a5d5cddac9f2866c7d
parent796cd312acc73ec612dcd0f8b297858a351a8198
[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)

This patch converts the DAGCombine isNegatibleForFree/GetNegatedExpression into overridable TLI hooks.

The intention is to let us extend existing FNEG combines to work more generally with negatible float ops, allowing it work with target specific combines and opcodes (e.g. X86's FMA variants).

Unlike the SimplifyDemandedBits, we can't just handle target nodes through a Target callback, we need to do this as an override to allow targets to handle generic opcodes as well. This does mean that the target implementations has to duplicate some checks (recursion depth etc.).

Partial reversion of rL372756 - I've identified the infinite loop issue inside the X86 override but haven't fixed it yet so I've only (re)committed the common TargetLowering refactoring part of the patch.

Differential Revision: https://reviews.llvm.org/D67557

llvm-svn: 373343
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp