diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-04-20 16:17:13 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-04-20 16:17:13 +0000 |
commit | a8129a11222249d5072c132927dbf9d402b5f9da (patch) | |
tree | 5a449591a98fa76421c1dd0297c2a5a074f94091 /llvm/lib/Transforms | |
parent | b7701bc9af13662f9658cf6a9db50daad3affd90 (diff) | |
download | bcm5719-llvm-a8129a11222249d5072c132927dbf9d402b5f9da.tar.gz bcm5719-llvm-a8129a11222249d5072c132927dbf9d402b5f9da.zip |
[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
llvm-svn: 300851
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index c5328c77abb..0cee474320b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -38,7 +38,7 @@ static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, // If there are no bits set that aren't demanded, nothing to do. Demanded = Demanded.zextOrTrunc(C->getBitWidth()); - if ((~Demanded & *C) == 0) + if (C->isSubsetOf(Demanded)) return false; // This instruction is producing bits that are not demanded. Shrink the RHS. |