mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-14 15:33:34 +00:00
Simplify isHighOnes().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
07073e5f70
commit
2cde46cb66
@ -3491,15 +3491,7 @@ static bool isLowOnes(const ConstantInt *CI) {
|
||||
// isHighOnes - Return true if the constant is of the form 1+0+.
|
||||
// This is the same as lowones(~X).
|
||||
static bool isHighOnes(const ConstantInt *CI) {
|
||||
if (CI->getValue() == 0) return false; // 0's does not match "1+"
|
||||
|
||||
APInt V(~CI->getValue());
|
||||
|
||||
// There won't be bits set in parts that the type doesn't contain.
|
||||
V &= APInt::getAllOnesValue(CI->getType()->getBitWidth());
|
||||
|
||||
APInt U(V+1); // If it is low ones, this should be a power of two.
|
||||
return (U!=0) && (V!=0) && (U & V) == 0;
|
||||
return (~CI->getValue() + 1).isPowerOf2();
|
||||
}
|
||||
|
||||
/// getICmpCode - Encode a icmp predicate into a three bit mask. These bits
|
||||
|
Loading…
x
Reference in New Issue
Block a user