llvm / llvm/llvm-project

Uncountable early exit loop vectorization with tail folding

Open
#179,595 1 comment 0 reactions 1 assignee Claimed by @lukel97 View on GitHub
vectorizers
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.