[llvm] [InstCombine] Fold `(trunc X)` into `X & Mask` inside `decomposeBitTestICmp` (PR #171195)
Andreas Jonson via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 4 02:50:23 PST 2026
================
@@ -153,15 +153,26 @@ llvm::decomposeBitTestICmp(Value *LHS, Value *RHS, CmpInst::Predicate Pred,
case ICmpInst::ICMP_NE: {
assert(DecomposeAnd);
const APInt *AndC;
- Value *AndVal;
- if (match(LHS, m_And(m_Value(AndVal), m_APIntAllowPoison(AndC)))) {
- LHS = AndVal;
+ Value *X;
+
+ if (match(LHS, m_And(m_Value(X), m_APIntAllowPoison(AndC)))) {
+ LHS = X;
Result.Mask = *AndC;
Result.C = C;
Result.Pred = Pred;
break;
}
+ // Try to convert (trunc X) eq/ne C into (X & Mask) eq/ne C
+ if (LookThroughTrunc && match(LHS, m_Trunc(m_Value(X)))) {
----------------
andjo403 wrote:
to me it sounds a bit strange that this is guarded by DecomposeAnd as there is no and in this case but I do not know
https://github.com/llvm/llvm-project/pull/171195
More information about the llvm-commits
mailing list