[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 19 Sep 2019 15:02:47 +0000 (15:02 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 19 Sep 2019 15:02:47 +0000 (15:02 +0000)
commitaf6043557dd1478beff83c44b21dd07b5e322c15
tree6ea597c86bb56d9d6a33bd55a625706627388954
parent9e94ef42bab003026a433687d9f44d8137f16d17
[DAG][X86] Convert isNegatibleForFree/GetNegatedExpression to a target hook (PR42863)

This patch converts the DAGCombine isNegatibleForFree/GetNegatedExpression into overridable TLI hooks and includes a demonstration X86 implementation.

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.).

I've only begun to replace X86's FNEG handling here, handling FMADDSUB/FMSUBADD negation and some low impact codegen changes (some FMA negatation propagation). We can build on this in future patches.

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

llvm-svn: 372333
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/recip-fastmath.ll
llvm/test/CodeGen/X86/recip-fastmath2.ll