[llvm] [WebAssembly] Add fold support for dot (PR #151775)

Jasmine Tang via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 12:01:07 PDT 2025


================
@@ -3436,6 +3439,53 @@ static SDValue performSETCCCombine(SDNode *N,
   return SDValue();
 }
 
+static SDValue performAddCombine(SDNode *N, SelectionDAG &DAG) {
+  assert(N->getOpcode() == ISD::ADD);
+  EVT VT = N->getValueType(0);
+  SDValue N0 = N->getOperand(0), N1 = N->getOperand(1);
+
+  if (VT != MVT::v4i32)
+    return SDValue();
+
+  auto IsShuffleWithMask = [](SDValue V, ArrayRef<int> ShuffleValue) {
+    if (V.getOpcode() != ISD::VECTOR_SHUFFLE)
+      return SDValue();
+    if (cast<ShuffleVectorSDNode>(V)->getMask() != ShuffleValue)
+      return SDValue();
+    return V;
+  };
+  auto ShuffleA = IsShuffleWithMask(N0, {0, 2, 4, 6});
+  auto ShuffleB = IsShuffleWithMask(N1, {1, 3, 5, 7});
+  // two SDValues must be muls
----------------
badumbatish wrote:

i just added the test, it seems that changing the shuffles doesn't affect how the optimization works!

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


More information about the llvm-commits mailing list