[llvm] [DAG] Fold mul 0 -> 0 when expanding mul into parts. (PR #168780)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 08:25:36 PST 2025


================
@@ -11096,10 +11095,14 @@ void TargetLowering::forceExpandMultiply(SelectionDAG &DAG, const SDLoc &dl,
   // If HiLHS and HiRHS are set, multiply them by the opposite low part and add
   // the products to Hi.
   if (HiLHS) {
-    Hi = DAG.getNode(ISD::ADD, dl, VT, Hi,
-                     DAG.getNode(ISD::ADD, dl, VT,
-                                 DAG.getNode(ISD::MUL, dl, VT, HiRHS, LHS),
-                                 DAG.getNode(ISD::MUL, dl, VT, RHS, HiLHS)));
+    Hi = DAG.getNode(
+        ISD::ADD, dl, VT, Hi,
+        DAG.getNode(
+            ISD::ADD, dl, VT,
+            isNullConstant(HiRHS) ? HiRHS
----------------
RKSimon wrote:

+` I'd much prefer we just added similar `N2CV->isZero()` handling to what we do for ISD::AND

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


More information about the llvm-commits mailing list