Skip to content

Commit

Permalink
Merge pull request #147 from chfast/div_unlikely
Browse files Browse the repository at this point in the history
Mark unlikely parts of division
  • Loading branch information
chfast authored Jun 15, 2020
2 parents 305e4cf + 8e2810d commit 0c59fcd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/intx/div.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void udivrem_knuth(uint64_t q[], uint64_t u[], int ulen, const uint64_t d[], int
const auto u0 = u[j + dlen - 2];

uint64_t qhat;
if (uint128{u2, u1} == divisor) // Division overflows.
if (UNLIKELY(uint128(u2, u1) == divisor)) // Division overflows.
{
qhat = ~uint64_t{0};

Expand All @@ -139,7 +139,7 @@ void udivrem_knuth(uint64_t q[], uint64_t u[], int ulen, const uint64_t d[], int
std::tie(u[j + dlen - 2], carry) = sub_with_carry(rhat.lo, overflow);
std::tie(u[j + dlen - 1], carry) = sub_with_carry(rhat.hi, carry);

if (carry)
if (UNLIKELY(carry))
{
--qhat;
u[j + dlen - 1] += divisor.hi + add(&u[j], &u[j], d, dlen - 1);
Expand Down

0 comments on commit 0c59fcd

Please sign in to comment.