Skip to content

Optimize foldings of repeated sorted values, if the reducer is distributive #118731

@Rudxain

Description

@Rudxain

I go into further detail here

I'm aware this optimization may be considered "too niche", but I believe it makes more sense for a compiler to do this automatically than for a human to explicitly use this algorithm at runtime.

I'm also aware of the fact that it would be unlikely for an optimizer to infer that a dynamically-generated list has all of its values sorted and that the set of unique values is small relative to the list length.

However, it's much easier to apply this optimization if the list contents are statically-known. Yes, the optimizer might prefer to do constant-folding, but if the list is big enough it might be better to fold at runtime, where this optimization shines

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions