summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorQingShan Zhang <qshanz@cn.ibm.com>2020-01-09 03:41:36 +0000
committerQingShan Zhang <qshanz@cn.ibm.com>2020-01-09 04:33:46 +0000
commitd48ac7d54d8a096677c84cfb2928400e05b918ea (patch)
treed9d9fde71e0263cb6226b22a28a51bde5057d776 /llvm/lib
parentde3d0ee023cb14c06d5be01369ef8db4cbfa16b4 (diff)
downloadbcm5719-llvm-d48ac7d54d8a096677c84cfb2928400e05b918ea.tar.gz
bcm5719-llvm-d48ac7d54d8a096677c84cfb2928400e05b918ea.zip
[DAGCombine] Fold the (fma -x, y, -z) to -(fma x, y, z)
This is a positive combination as long as the NEG is NOT free, as we are reducing the number of NEG from two to one. Differential Revision: https://reviews.llvm.org/D72312
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index cfc4671eaa0..37b1b17218d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12639,6 +12639,15 @@ SDValue DAGCombiner::visitFMA(SDNode *N) {
}
}
+ // fold ((fma (fneg X), Y, (fneg Z)) -> fneg (fma X, Y, Z))
+ // fold ((fma X, (fneg Y), (fneg Z)) -> fneg (fma X, Y, Z))
+ if (!TLI.isFNegFree(VT) &&
+ TLI.isNegatibleForFree(SDValue(N, 0), DAG, LegalOperations,
+ ForCodeSize) == 2)
+ return DAG.getNode(ISD::FNEG, DL, VT,
+ TLI.getNegatedExpression(SDValue(N, 0), DAG,
+ LegalOperations, ForCodeSize),
+ Flags);
return SDValue();
}
OpenPOWER on IntegriCloud