mirror of https://github.com/YosysHQ/yosys.git
nowrshmsk: Check for stride==0
log2(0) returns -inf, which gives undefined behaviour when casting to an int. So catch the case when it's 0 just set the width to 0.
This commit is contained in:
parent
31b00b4c72
commit
cf52cf3009
|
@ -2936,6 +2936,9 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
||||||
lsb_expr->children[stride_ix]->detectSignWidth(stride_width, stride_sign);
|
lsb_expr->children[stride_ix]->detectSignWidth(stride_width, stride_sign);
|
||||||
max_width = std::max(i_width, stride_width);
|
max_width = std::max(i_width, stride_width);
|
||||||
// Stride width calculated from actual stride value.
|
// Stride width calculated from actual stride value.
|
||||||
|
if (stride == 0)
|
||||||
|
stride_width = 0;
|
||||||
|
else
|
||||||
stride_width = std::ceil(std::log2(std::abs(stride)));
|
stride_width = std::ceil(std::log2(std::abs(stride)));
|
||||||
|
|
||||||
if (i_width + stride_width > max_width) {
|
if (i_width + stride_width > max_width) {
|
||||||
|
|
Loading…
Reference in New Issue