[llvm] [DAGCombiner] Fold pattern for srl-shl-zext (PR #138290)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 14:04:16 PDT 2025


================
@@ -10979,6 +10979,39 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
       return DAG.getNode(ISD::SRL, DL, VT, N0, NewOp1);
   }
 
+  // fold (srl (or x, (shl (zext y), c1)), c1) -> (or (srl x, c1), (zext y))
+  // c1 <= leadingzeros(zext(y))
+  if (N1C && (N0.getOpcode() == ISD::OR || N0.getOpcode() == ISD::AND ||
+              N0.getOpcode() == ISD::XOR)) {
----------------
RKSimon wrote:

Since #138301 we now have m_BitwiseLogic if you wanted to use SDPatternMatch to simplify the commutative matching - but this is is optional.

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


More information about the llvm-commits mailing list