Loop Vectorization : AllocateLoop


This is regarding the below code snip from loop vectorizer:

void VPRegionBlock::execute(VPTransformState *State) {
ReversePostOrderTraversal<VPBlockBase *> RPOT(Entry);

if (!isReplicator()) {
// Create and register the new vector loop.
Loop *PrevLoop = State->CurrentVectorLoop;
State->CurrentVectorLoop = State->LI->AllocateLoop();

Earlier the AllocateLoop was part of createVectorLoopSkeleton, and it was always created.

But with this recent change its guarded under a condition.

I did not understood the intent of this condition completely, can someone share more details why it’s called conditionally ?


There are 2 kinds of VPRegionBlock: replicate-regions and loop regions. Loop objects only need to be created for loop-regions as they will result in a loop in the generated IR.

Thanks Florian for the details.