[llvm] [AMDGPU] Fold mul24 with an operand whose low 24 bits are zero (PR #224537)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 09:56:33 PDT 2026


================
@@ -4087,23 +4087,26 @@ static SDValue simplifyMul24(SDNode *Node24,
 
   APInt Demanded = APInt::getLowBitsSet(LHS.getValueSizeInBits(), 24);
 
-  // First try to simplify using SimplifyMultipleUseDemandedBits which allows
-  // the operands to have other uses, but will only perform simplifications that
-  // involve bypassing some nodes for this user.
-  SDValue DemandedLHS = TLI.SimplifyMultipleUseDemandedBits(LHS, Demanded, DAG);
-  SDValue DemandedRHS = TLI.SimplifyMultipleUseDemandedBits(RHS, Demanded, DAG);
-  if (DemandedLHS || DemandedRHS)
-    return DAG.getNode(NewOpcode, SDLoc(Node24), Node24->getVTList(),
-                       DemandedLHS ? DemandedLHS : LHS,
-                       DemandedRHS ? DemandedRHS : RHS);
+  if (isNullConstant(LHS) || isNullConstant(RHS))
+    return DAG.getConstant(0, SDLoc(Node24), Node24->getValueType(0));
 
-  // Now try SimplifyDemandedBits which can simplify the nodes used by our
+  // First try SimplifyDemandedBits which can simplify the nodes used by our
   // operands if this node is the only user.
   if (TLI.SimplifyDemandedBits(LHS, Demanded, DCI))
     return SDValue(Node24, 0);
   if (TLI.SimplifyDemandedBits(RHS, Demanded, DCI))
     return SDValue(Node24, 0);
 
+  // Then try SimplifyMultipleUseDemandedBits which allows the operands to have
+  // other uses, but will only perform simplifications that involve bypassing
+  // some nodes for this user.
+  SDValue DemandedLHS = TLI.SimplifyMultipleUseDemandedBits(LHS, Demanded, DAG);
----------------
arsenm wrote:

Should this replace the SImplifyDemandedBits calls above? I don't expect to see both in sequence, at least without a hasOneUse check 

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


More information about the llvm-commits mailing list