[llvm-branch-commits] [llvm] [RISCV] Combine vwaddu_wv+vabd(u) to vwabda(u) (PR #184603)

Pengcheng Wang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 10 23:59:22 PDT 2026


https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/184603

>From 5111b034482743376fd40b535bbac3f2de3ca017 Mon Sep 17 00:00:00 2001
From: Pengcheng Wang <wangpengcheng.pp at bytedance.com>
Date: Tue, 10 Mar 2026 10:38:08 +0800
Subject: [PATCH] Use std::swap

Created using spr 1.3.6-beta.1
---
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 23 +++++++--------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index f3ead374a8744..b1ef2bb561282 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -25,7 +25,6 @@
 #include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Analysis/VectorUtils.h"
-#include "llvm/CodeGen/ISDOpcodes.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -19199,20 +19198,14 @@ static SDValue performVWABDACombineWV(SDNode *N, SelectionDAG &DAG,
     return Op;
   };
 
-  auto ExtractOps = [&](SDValue Op0,
-                        SDValue Op1) -> std::pair<SDValue, SDValue> {
-    SDValue Diff = GetDiff(Op0);
-    if (Diff)
-      return {Op1, Diff};
-    Diff = GetDiff(Op1);
-    if (Diff)
-      return {Op0, Diff};
-    return {};
-  };
-
-  auto [Acc, Diff] = ExtractOps(Op0, Op1);
-  if (!Diff)
-    return SDValue();
+  SDValue Diff = GetDiff(Op0);
+  if (!Diff) {
+    std::swap(Op0, Op1);
+    Diff = GetDiff(Op0);
+    if (!Diff)
+      return SDValue();
+  }
+  SDValue Acc = Op1;
 
   SDLoc DL(N);
   SDValue DiffA = Diff.getOperand(0);



More information about the llvm-branch-commits mailing list