[llvm] [InstCombine] Fold icmp (zext X), (and (trunc Y), Mask) -> icmp X, trunc Y (PR #221189)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 10:51:14 PDT 2026
================
@@ -5825,6 +5826,23 @@ Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I,
if (Value *V = foldShiftIntoShiftInAnotherHandOfAndInICmp(I, SQ, Builder))
return replaceInstUsesWith(I, V);
+ // icmp (zext X), (and (trunc Y), Mask) -> icmp X, trunc Y IFF Mask exactly
+ // covers the bits of X
+ {
+ Value *Y;
+ const APInt *Mask;
+ if (!I.isSigned() && match(I.getOperand(1), m_ZExt(m_Value(X))) &&
----------------
dtcxzyw wrote:
check `shouldChangeType`.
https://github.com/llvm/llvm-project/pull/221189
More information about the llvm-commits
mailing list