Skip to content

[RISCV][LoopUnroll/CostModel] Loops with Insert/Extract element using induction variable without vector are not unrolled #92366

Open
@joe-img

Description

@joe-img

Without vector, extractelement/insertelement with non-constant index can be very costly.
This was factored into the cost model in #67334

However, in the case of full canonical loop unrolling and the index being the induction variable, the index will be constant, but is not at the time of estimating the cost of unrolling the loop.

Example before and after this change: (llvm 17 vs 18)
https://compiler-explorer.com/z/Mh6eWKjr7

I had a go at fixing this myself, but could not see a good fix. I ended up abusing ephemeral values that get passed into UnrollCostEstimator.

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