[PATCH] D151660: [InstCombine] (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1)
Shivam Gupta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 21:46:41 PDT 2023
xgupta updated this revision to Diff 527727.
xgupta added a comment.
Remove TODO
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151660/new/
https://reviews.llvm.org/D151660
Files:
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2947,6 +2947,16 @@
Constant::getNullValue(NewOr->getType()));
}
+ // (icmp ne A, -1) | (icmp ne B, -1) --> (icmp ne (A&B), -1)
+ // (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1)
+ if (!IsLogical && PredL == (IsAnd ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_NE) &&
+ PredL == PredR && match(LHS1, m_AllOnes()) && match(RHS1, m_AllOnes()) &&
+ LHS0->getType() == RHS0->getType()) {
+ Value *NewAnd = Builder.CreateAnd(LHS0, RHS0);
+ return Builder.CreateICmp(PredL, NewAnd,
+ Constant::getAllOnesValue(LHS0->getType()));
+ }
+
// This only handles icmp of constants: (icmp1 A, C1) | (icmp2 B, C2).
if (!LHSC || !RHSC)
return nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151660.527727.patch
Type: text/x-patch
Size: 989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230602/7ddc4d81/attachment.bin>
More information about the llvm-commits
mailing list