Skip to content

Uncountable early exit loop vectorization with tail folding #179595

@lukel97

Description

@lukel97

Currently the loop vectorizer can't tail fold a loop if the loop has an early exit. It's currently guarded by a check in LoopVectorizationLegality::canFoldTailByMasking.

We would need to compute the last active lane as the minimum of the first active lane of the exit condition, and the last active lane of the header mask.

Eventually loops with early exits may need to also predicate recipes after the exit, like in #172454. In this case we would need to logically and both predication masks in the vector loop body.

As a first step, #176143 aims to generalize tail folding predication by explicitly representing it in the CFG so VPlanPredicator "automatically" handles it, which could then be reused for early exit predication.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions