[llvm] [InstCombine] Fold Minimum over trailing or leading zeros (PR #173768)
Aryan Kadole via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 28 11:31:11 PST 2025
================
@@ -1700,12 +1702,18 @@ foldMinimumOverTrailingOrLeadingZeroCount(Value *I0, Value *I1,
static_assert(IntrID == Intrinsic::cttz || IntrID == Intrinsic::ctlz,
"This helper only supports cttz and ctlz intrinsics");
- Value *CtOp;
- Value *ZeroUndef;
- if (!match(I0,
- m_OneUse(m_Intrinsic<IntrID>(m_Value(CtOp), m_Value(ZeroUndef)))))
+ Value *CtOp1, *CtOp2;
+ Value *ZeroUndef1, *ZeroUndef2;
+ if (!match(I0, m_OneUse(
+ m_Intrinsic<IntrID>(m_Value(CtOp1), m_Value(ZeroUndef1)))))
return nullptr;
+ if (match(I1,
+ m_OneUse(m_Intrinsic<IntrID>(m_Value(CtOp2), m_Value(ZeroUndef2)))))
+ return Builder.CreateBinaryIntrinsic(
+ IntrID, Builder.CreateOr(CtOp1, CtOp2),
+ ConstantInt::getTrue(ZeroUndef1->getType()));
----------------
ak1932 wrote:
Yes, I forgot to comment that I did not know what to set the flag to. Should it be true if either of the flags are true?
https://github.com/llvm/llvm-project/pull/173768
More information about the llvm-commits
mailing list