[llvm] [DAGCombiner][VP] Add DAGCombine for VP_MUL (PR #80105)

Jianjian Guan via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 3 22:10:57 PST 2024


================
@@ -4404,20 +4408,21 @@ SDValue DAGCombiner::visitMUL(SDNode *N) {
   if (N1IsConst && ConstValue1.isOne())
     return N0;
 
-  if (SDValue NewSel = foldBinOpIntoSelect(N))
-    return NewSel;
+  if (!IsVP)
+    if (SDValue NewSel = foldBinOpIntoSelect(N))
+      return NewSel;
 
   // fold (mul x, -1) -> 0-x
   if (N1IsConst && ConstValue1.isAllOnes())
-    return DAG.getNegative(N0, DL, VT);
+    return Matcher.getNode(ISD::SUB, DL, VT, DAG.getConstant(0, DL, VT), N0);
----------------
jacquesguan wrote:

It seems lots of amounts of helper functions that like `getNegative`, maybe need to find a way to reuse the same logic to avoid duplicated code.

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


More information about the llvm-commits mailing list