Skip to content

Commit

Permalink
Replace calls to ceil(log2(x)) with ceil_log2(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
daglem committed Mar 15, 2024
1 parent efc9e75 commit 5da55a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontends/ast/simplify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
lsb_expr->children[stride_ix]->detectSignWidth(stride_width, stride_sign);
shift_expr_width_max = std::max(i_width, stride_width);
// Stride width calculated from actual stride value.
stride_width = std::ceil(std::log2(std::abs(stride)));
stride_width = ceil_log2(std::abs(stride));

if (i_width + stride_width > shift_expr_width_max) {
// For (truncated) i*stride to be within the range of dst, the following must hold:
Expand Down Expand Up @@ -3066,7 +3066,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
lsb_expr->children[stride_ix]->detectSignWidth(stride_width, stride_sign);
max_width = std::max(i_width, stride_width);
// Stride width calculated from actual stride value.
stride_width = std::ceil(std::log2(std::abs(stride)));
stride_width = ceil_log2(std::abs(stride));

if (i_width + stride_width > max_width) {
// For (truncated) i*stride to be within the range of dst, the following must hold:
Expand Down

0 comments on commit 5da55a8

Please sign in to comment.