Skip to content

Wrong type in __count_leading_zeros_varying_i64 in generic.ispc #3833

@zephyr111

Description

@zephyr111

While implementing a new feature, I just found out that the function __count_leading_zeros_varying_i64 in generic.ispc internally store the result into a 32-bit integer variable while the function returns a 64-bit type. Do you agree? If so, should the function return a 32-bit int or the result be a 64-bit one? Considering the function in the doc, I would say that this is the former (32-bit return type).

The same thing likely also applies on __count_trailing_zeros_varying_i64 and the uniform versions (__count_trailing_zeros_uniform_i64 and __count_leading_zeros_uniform_i64). What about using an explicit cast like in __popcnt_xxx?

Besides, in the documentation, the output type is not clear for 64-bit types since it is not explicitly reported:

A few functions determine how many leading bits in the given value are zero and how many of the trailing bits are zero;
there are also unsigned variants of these functions and variants that take int64 and unsigned int64 types.

int32 count_leading_zeros(int32 v)
uniform int32 count_leading_zeros(uniform int32 v)
int32 count_trailing_zeros(int32 v)
uniform int32 count_trailing_zeros(uniform int32 v)

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionGeneral questions.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions