Skip to content

Commit

Permalink
KnownBits: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
artagnon committed Sep 23, 2024
1 parent 3622e43 commit 3c3e080
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions llvm/lib/Support/KnownBits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,14 +1076,12 @@ KnownBits KnownBits::srem(const KnownBits &LHS, const KnownBits &RHS) {
// The sign bit is the LHS's sign bit, except when the result of the
// remainder is zero. The magnitude of the result should be less than or
// equal to the magnitude of either operand.
if (LHS.isNegative() && Known.isNonZero()) {
if (LHS.isNegative() && Known.isNonZero())
Known.One.setHighBits(
std::max(LHS.countMinLeadingOnes(), RHS.countMinSignBits()));
} else if (LHS.isNonNegative()) {
unsigned Lead =
std::max(LHS.countMinLeadingZeros(), RHS.countMinLeadingZeros());
Known.Zero.setHighBits(std::max(Lead + 1, RHS.countMinLeadingOnes()) - 1);
}
else if (LHS.isNonNegative())
Known.Zero.setHighBits(
std::max(LHS.countMinLeadingZeros(), RHS.countMinSignBits()));
return Known;
}

Expand Down

0 comments on commit 3c3e080

Please sign in to comment.