Skip to content

Optimize the next-power-of-two calculation in vectors for code size #15390

Closed
@pcwalton

Description

@pcwalton

Currently it's more general than it needs to be, resulting in the next-power-of-two code appearing in lots of places due to inlining. But vec capacities are usually powers of two. I think it should be something like:

if popcount(capacity) != 1 {
    // non-power-of-two case
    capacity_slow()
} else {
    capacity << 1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions