[llvm] [DAGCombine]Fold (fadd A, Splat(fneg(B))) -> (fsub A, Splat(B)) (PR #173967)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 30 05:27:24 PST 2025
================
@@ -17965,6 +17965,19 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
N0, DAG, LegalOperations, ForCodeSize))
return DAG.getNode(ISD::FSUB, DL, VT, N1, NegN0);
+ // fold (fadd A, Splat(fneg(B))) -> (fsub A, Splat(B))
+ if (VT.isVector() &&
+ (!LegalOperations || TLI.isOperationLegalOrCustom(ISD::FSUB, VT))) {
+ if (N1.getOpcode() == ISD::SPLAT_VECTOR) {
+ SDValue SplatN0 = N1->getOperand(0);
+ if (SplatN0.getOpcode() == ISD::FNEG && SplatN0.hasOneUse()) {
----------------
arsenm wrote:
Probably should be ignoring use count if fneg is free?
https://github.com/llvm/llvm-project/pull/173967
More information about the llvm-commits
mailing list