llvm::expandReductionViaLoop

Expand a scalable vector reduction into an element-wise runtime loop.

Synopsis

Declared in <llvm/Transforms/Utils/LoopUtils.h>

Value*
expandReductionViaLoop(
    IRBuilderBase& Builder,
    Value* Vec,
    unsigned int RdxOpcode,
    Value* Acc,
    DominatorTree* DT = nullptr,
    LoopInfo* LI = nullptr);

Description

Expand a scalable vector reduction into a runtime loop that applies RdxOpcode element by element, starting from Acc as the initial accumulator value (typically the reduction identity). If DT and/or LI are provided, they are updated to reflect the new basic blocks.

Return Value

The reduced scalar value.

Parameters

NameDescription
BuilderIR builder positioned where the loop should be emitted.
VecScalable vector value being reduced.
RdxOpcodeOpcode applied to each extracted element.
AccInitial accumulator / identity value.
DTOptional dominator tree to update.
LIOptional loop info to update.