[llvm] [AArch64][Codegen]Transform saturating smull to sqdmulh (PR #143671)
Nashe Mncube via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 08:54:56 PDT 2025
================
@@ -20918,6 +20928,79 @@ static SDValue performBuildVectorCombine(SDNode *N,
return SDValue();
}
+// A special combine for the sqdmulh family of instructions.
+// smin( sra ( mul( sext v0, sext v1 ) ), SHIFT_AMOUNT ),
+// SATURATING_VAL ) can be reduced to sext(sqdmulh(...))
+static SDValue trySQDMULHCombine(SDNode *N, SelectionDAG &DAG) {
+
+ if (N->getOpcode() != ISD::TRUNCATE)
----------------
nasherm wrote:
I'm not sure if you mean starting the combine at SMIN, or calling the combine from a "performSMINCombine" call. I don't believe the latter is possible (at least in a similar way to what I have already) in our test case because the DAG is defined with the SMIN nodes being child nodes of a the `truncate` call.
I could be understanding this wrong but it seems that the `performDAGCombine` call pattern matches on parent (root?) nodes of a DAG. Meaning we don't necessarily know if there's an SMIN child node when attempting combines without traversing the child nodes.
However, if you meant just starting the `trySQDMULHCombine` call from SMIN, then yes that's easy.
https://github.com/llvm/llvm-project/pull/143671
More information about the llvm-commits
mailing list