[llvm] [InstCombine] Decompose an icmp into multiple ranges (PR #69855)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 21 22:39:05 PDT 2023
================
@@ -1334,6 +1334,101 @@ Value *InstCombinerImpl::foldAndOrOfICmpsUsingRanges(ICmpInst *ICmp1,
return Builder.CreateICmp(NewPred, NewV, ConstantInt::get(Ty, NewC));
}
+/// Decompose icmp into intersection or union of ranges.
+static bool decomposeICmpIntoRangeSet(SmallVectorImpl<ConstantRange> &Set,
+ ICmpInst *ICmp, Value *X, bool IsAnd) {
+ // icmp eq/ne (X & mask), 0
+ ICmpInst::Predicate Pred;
+ const APInt *Mask;
+ if (match(ICmp,
+ m_ICmp(Pred, m_And(m_Specific(X), m_APInt(Mask)), m_Zero())) &&
+ ICmp->isEquality()) {
+ if (Mask->popcount() == Mask->getBitWidth() - 1) {
----------------
goldsteinn wrote:
Just a personal style thing, but would put this in the above if statement.
https://github.com/llvm/llvm-project/pull/69855
More information about the llvm-commits
mailing list