[PATCH] D43835: Simplify more cases of logical ops of masked icmps.
David Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 12 11:18:40 PDT 2018
davidxl added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:499
+ // For example,
+ // (icmp ne (A & 12), 0) & (icmp eq (A & 7), 1) -> (icmp eq (A & 15), 9)
+ // (icmp ne (A & 15), 0) & (icmp eq (A & 7), 0) -> (icmp eq (A & 15), 8)
----------------
This check can probably be extended:
1) B's bitset subtracts the intersection of B and D contains only one bit
2) B and D's intersection have zero values
In other words, D does not need to be power of 2
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:530
+ // (icmp ne (A & 15), 0) & (icmp eq (A & 3), 0) -> no folding.
+ if (ECst->isZero()) {
+ if ((BCst->getValue() & DCst->getValue()) == BCst->getValue())
----------------
Can you introduce a small lambda here to be reused here and other places?
auto IsSubset = [](Value *V1, Value *V2) {
....
};
if (IsSubset(BCst, DCst)) ....
================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:536
+
+ // At this point, B, D, E aren't zero and (B & D) == B, (B & D) == D or B ==
+ // D. If B is a superset of (or equal to) D, since E is not zero, LHS is
----------------
Can you split the comment here for case in line 548 and line 552?
Repository:
rL LLVM
https://reviews.llvm.org/D43835
More information about the llvm-commits
mailing list