[llvm] [SDAG] (abd? (?ext x), c) -> (zext (abd? x, c)) (PR #176366)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 16 12:25:11 PST 2026


================
@@ -5812,6 +5812,28 @@ SDValue DAGCombiner::visitABD(SDNode *N) {
     }
   }
 
+  APInt YConst;
+  // fold (abd? (?ext ty:x), small_const:c) -> (zext (abd? x, c))
+  if (sd_match(N, m_c_BinOp(ISD::ABDU, m_ZExt(m_Value(X)), m_Value(Y))) ||
+      sd_match(N, m_c_BinOp(ISD::ABDS, m_SExt(m_Value(X)), m_Value(Y)))) {
+    EVT SmallVT = X.getValueType();
+    auto Bits = SmallVT.getScalarSizeInBits();
+    bool IsConstSmall = ISD::matchUnaryPredicate(
----------------
DaKnig wrote:

done.

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


More information about the llvm-commits mailing list