[llvm] [SDAG] Shrink (abds (sext x) (sext y)) (PR #171865)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 09:18:46 PST 2025


================
@@ -5787,6 +5776,20 @@ SDValue DAGCombiner::visitABD(SDNode *N) {
       DAG.SignBitIsZero(N0) && DAG.SignBitIsZero(N1))
     return DAG.getNode(ISD::ABDU, DL, VT, N1, N0);
 
+  // fold (abds (sext x), (sext y)) -> (zext (abds x, y))
+  if (sd_match(N,
+               m_c_BinOp(ISD::ABDS, m_SExt(m_Value(X)), m_SExt(m_Value(Y)))) &&
+      X.getValueType() == Y.getValueType()) {
----------------
RKSimon wrote:

I think technically we don't need these to match - we just need to truncate to the larger of the types (removing one of the sext).

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


More information about the llvm-commits mailing list