Skip to content

Commit

Permalink
[KnownBits] isNonZero() - avoid expensive countPopulation call. NFC.
Browse files Browse the repository at this point in the history
We can just check for a null value.
  • Loading branch information
RKSimon committed Nov 8, 2020
1 parent e8dc17a commit 9fd7710
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Support/KnownBits.h
Expand Up @@ -98,7 +98,7 @@ struct KnownBits {
bool isNonNegative() const { return Zero.isSignBitSet(); }

/// Returns true if this value is known to be non-zero.
bool isNonZero() const { return One.countPopulation() != 0; }
bool isNonZero() const { return !One.isNullValue(); }

/// Returns true if this value is known to be positive.
bool isStrictlyPositive() const { return Zero.isSignBitSet() && !One.isNullValue(); }
Expand Down

0 comments on commit 9fd7710

Please sign in to comment.