mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04:00
[APInt] Add isSubsetOf method that can check if one APInt is a subset of another without creating temporary APInts
This question comes up in many places in SimplifyDemandedBits. This makes it easy to ask without allocating additional temporary APInts. The BitVector class provides a similar functionality through its (IMHO badly named) test(const BitVector&) method. Though its output polarity is reversed. I've provided one example use case in this patch. I plan to do more as a follow up. Differential Revision: https://reviews.llvm.org/D32258 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300851 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -730,6 +730,14 @@ bool APInt::intersectsSlowCase(const APInt &RHS) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool APInt::isSubsetOfSlowCase(const APInt &RHS) const {
|
||||
for (unsigned i = 0, e = getNumWords(); i != e; ++i)
|
||||
if ((pVal[i] & ~RHS.pVal[i]) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
APInt APInt::byteSwap() const {
|
||||
assert(BitWidth >= 16 && BitWidth % 16 == 0 && "Cannot byteswap!");
|
||||
if (BitWidth == 16)
|
||||
|
||||
Reference in New Issue
Block a user