[llvm] [DAG] Constant fold FMAD (PR #69324)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 05:43:55 PDT 2023


================
@@ -16752,6 +16755,22 @@ template <class MatchContextClass> SDValue DAGCombiner::visitFMA(SDNode *N) {
   return SDValue();
 }
 
+SDValue DAGCombiner::visitFMAD(SDNode *N) {
+  SDValue N0 = N->getOperand(0);
+  SDValue N1 = N->getOperand(1);
+  SDValue N2 = N->getOperand(2);
+  EVT VT = N->getValueType(0);
+  SDLoc DL(N);
+
+  // Constant fold FMAD.
+  if (isa<ConstantFPSDNode>(N0) && isa<ConstantFPSDNode>(N1) &&
----------------
RKSimon wrote:

I've been hoping to convert SelectionDAG::foldConstantFPMath to take a `ArrayRef<SDValue> Ops` arg instead of assuming a binop, but have never gotten around to it.

https://github.com/llvm/llvm-project/pull/69324


More information about the llvm-commits mailing list