[llvm] [InstCombine] Lower flag check pattern to use a bitmask-shift (PR #169557)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 21:25:34 PST 2025
================
@@ -3119,6 +3119,127 @@ static Instruction *matchFunnelShift(Instruction &Or, InstCombinerImpl &IC) {
return nullptr;
}
+static Value *combineOrOfImmCmpToBitExtract(Instruction &Or,
+ InstCombiner::BuilderTy &Builder,
+ const DataLayout &DL) {
+
+ auto isICmpEqImm = [](Value *N, ConstantInt *&Imm, Value *&X) -> bool {
+ if (X)
+ return match(N, m_OneUse(m_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(X),
+ m_ConstantInt(Imm))));
+
+ return match(N, m_OneUse(m_SpecificICmp(ICmpInst::ICMP_EQ, m_Value(X),
+ m_ConstantInt(Imm))));
+ };
+
+ // %srl = lshr %bitmap, %X
+ // %icmp = icmp ult %X, %max_value
+ // %trunc = trunc %srl to i1
+ // %sel = select %icmp, %trunc, false
+ auto CreateBitExtractSeq = [&](APInt BitMap, APInt MaxValue,
----------------
topperc wrote:
Pass APInt by const reference if possible. They might point to heap allocated memory which would need to be copied.
https://github.com/llvm/llvm-project/pull/169557
More information about the llvm-commits
mailing list