[llvm] [NVPTX] Improve folding to mad with immediate 1 (PR #93628)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue May 28 18:57:04 PDT 2024


================
@@ -5614,17 +5614,98 @@ static SDValue TryMULWIDECombine(SDNode *N,
   return DCI.DAG.getNode(Opc, DL, MulType, TruncLHS, TruncRHS);
 }
 
+static SDValue matchMADConstOnePattern(SDValue X, SDValue Add) {
+  if (Add->getOpcode() != ISD::ADD)
+    return SDValue();
+
+  SDValue Y = Add->getOperand(0);
+  ConstantSDNode *Const = dyn_cast<ConstantSDNode>(Add->getOperand(1));
+  if (!Const || Const->getZExtValue() != 1)
----------------
Artem-B wrote:

Nit. Phrasing the condition in positive terms would be more readable, IMO. 
`if (Const && Const->getZExtValue() == 1) return Y;`


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


More information about the llvm-commits mailing list