[llvm] [InstCombine] Fold Minimum over Trailing/Leading Bits Counts (PR #90402)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 4 13:45:09 PDT 2024


================
@@ -1633,6 +1667,21 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
       Value *Cmp = Builder.CreateICmpNE(I0, Zero);
       return CastInst::Create(Instruction::ZExt, Cmp, II->getType());
     }
+    // umin(cttz(x), const) --> cttz(x | (1 << const))
+    Value *X;
+    Constant *Y;
+    Value *Z;
+    if (match(I0, m_OneUse(m_Cttz(m_Value(X), m_Value(Z)))) &&
+        match(I1, m_Constant(Y))) {
----------------
mskamp wrote:

I've replaced the matcher with `m_CheckedInt`.

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


More information about the llvm-commits mailing list