[llvm] [InstCombine] Add combines for `(icmp eq/ne (and X, P2), (and X, -P2))` (PR #94867)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 9 12:24:15 PDT 2024
================
@@ -5570,10 +5570,35 @@ Instruction *InstCombinerImpl::foldICmpEquality(ICmpInst &I) {
Z = B;
}
- if (X) { // Build (X^Y) & Z
- Op1 = Builder.CreateXor(X, Y);
- Op1 = Builder.CreateAnd(Op1, Z);
- return new ICmpInst(Pred, Op1, Constant::getNullValue(Op1->getType()));
+ if (X) {
+ // (X&P2) == (X&-P2)
+ // -> X u< P2*2
+ // (X&P2) != (X&-P2)
+ // -> X u>= P2*2
+ // iff P2 is not INT_MIN
----------------
goldsteinn wrote:
Okay its not so complicated. All we really need to do is relax the restrictions on the existing fold if we have the NegP2 case.
https://github.com/llvm/llvm-project/pull/94867
More information about the llvm-commits
mailing list