[llvm] [SDAG] Shrink (abd? (?ext x) (?ext y)) (PR #171865)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 03:55:35 PST 2025
================
@@ -5787,6 +5787,23 @@ SDValue DAGCombiner::visitABD(SDNode *N) {
DAG.SignBitIsZero(N0) && DAG.SignBitIsZero(N1))
return DAG.getNode(ISD::ABDU, DL, VT, N1, N0);
+ // fold (abds (?ext x), (?ext y)) -> (zext (abd? x, y))
+ if (sd_match(N,
+ m_c_BinOp(ISD::ABDU, m_ZExt(m_Value(X)), m_ZExt(m_Value(Y)))) ||
+ sd_match(N,
+ m_c_BinOp(ISD::ABDS, m_SExt(m_Value(X)), m_SExt(m_Value(Y))))) {
+ EVT SmallVT = X.getScalarValueSizeInBits() > Y.getScalarValueSizeInBits()
+ ? X.getValueType()
+ : Y.getValueType();
+ auto ExtedX = DAG.getExtOrTrunc(N0->getOpcode(), X, X, SmallVT);
+ auto ExtedY = DAG.getExtOrTrunc(N0->getOpcode(), Y, Y, SmallVT);
----------------
natanelh-mobileye wrote:
My bad. fixed.
I put X in place of DL so that it would take the SDLoc of X instead of N. this implicitly calls the SDLoc constructor on X. I now made it explicit.
https://github.com/llvm/llvm-project/pull/171865
More information about the llvm-commits
mailing list