[llvm] [LoopVectorizer] Add support for partial reductions (PR #92418)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 31 06:39:24 PDT 2024
================
@@ -113,18 +140,70 @@ class VPRecipeBuilder {
public:
VPRecipeBuilder(VPlan &Plan, Loop *OrigLoop, const TargetLibraryInfo *TLI,
+ const TargetTransformInfo *TTI,
LoopVectorizationLegality *Legal,
LoopVectorizationCostModel &CM,
PredicatedScalarEvolution &PSE, VPBuilder &Builder)
- : Plan(Plan), OrigLoop(OrigLoop), TLI(TLI), Legal(Legal), CM(CM),
- PSE(PSE), Builder(Builder) {}
+ : Plan(Plan), OrigLoop(OrigLoop), TLI(TLI), TTI(TTI), Legal(Legal),
+ CM(CM), PSE(PSE), Builder(Builder) {}
+
+ void addScaledReductionExitInstr(PartialReductionChain Chain) {
+ ScaledReductionExitInstrs.insert(std::make_pair(Chain.Reduction, Chain));
+ }
+
+ std::optional<PartialReductionChain>
+ getScaledReductionForInstr(const Instruction *ExitInst) {
+ auto It = ScaledReductionExitInstrs.find(ExitInst);
+ return It == ScaledReductionExitInstrs.end()
+ ? std::nullopt
+ : std::make_optional(It->second);
+ }
+
+ void removeInvalidScaledReductionExitInstrs() {
----------------
huntergr-arm wrote:
nit: the function body seems large enough that it should be moved into one of the .cpp files. (Maybe LoopVectorize.cpp?)
https://github.com/llvm/llvm-project/pull/92418
More information about the llvm-commits
mailing list