Skip to content

make the vector iterator use GEP, not ptrtoint + add + inttoptr #8212

Closed
@thestinger

Description

@thestinger

LLVM is currently incapable of analysing the alias implications of these conversions despite a set of rules being defined for them, so they're an opaque wall blocking optimizations. I fixed the offset family of functions in the ptr module but vectors are a bit problematic.

Vector iterators use a pointer to the start and a pointer one byte past the end, so an iteration of the loop is just an increment (or decrement, in reverse) of a pointer and a comparison between the start and end.

Since zero-size types can be stored in vectors, it currently uses nonzero_size_of to increment the pointer instead of the optimized offset functions - otherwise iterating of a vector of 11 zero-size types would stop immediately instead of looping 11 times. This can likely be fixed by special-casing the iterator for zero-size types.

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