[llvm] [RISCV] vfadd.vf + splat (fneg)-> vfsub.vf (PR #173589)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 26 16:59:33 PST 2025


================
@@ -21021,7 +21021,23 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
       return SDValue();
     return DAG.getNode(RISCVISD::FSGNJX, DL, VT, N1, N0->getOperand(1));
   }
-  case ISD::FADD:
+  case ISD::FADD: {
+    if (SDValue V = combineBinOpToReduce(N, DAG, Subtarget))
+      return V;
+    if (SDValue V = combineBinOpOfExtractToReduceTree(N, DAG, Subtarget))
+      return V;
+    SDValue N1 = N->getOperand(1);
+    if (!Subtarget.hasStdExtZfa() || N1.getOpcode() != ISD::SPLAT_VECTOR)
+      return SDValue();
+    SDValue SplatN0 = N1->getOperand(0);
+    if (!SplatN0.hasOneUse() || SplatN0.getOpcode() != ISD::FNEG)
----------------
topperc wrote:

Check the opcode before checking number of uses. Checking number of uses is expensive for opcodes that have more than 1 result.

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


More information about the llvm-commits mailing list