[llvm] [VPlan] Impl VPlan-based pattern match for ExtendedRed and MulAccRed (NFCI) (PR #113903)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 13:26:55 PST 2024
================
@@ -9387,6 +9330,171 @@ VPlanPtr LoopVectorizationPlanner::buildVPlan(VFRange &Range) {
return Plan;
}
+/// Try to match the extended-reduction and create VPExtendedReductionRecipe.
+///
+/// This function try to match following pattern which will generate
+/// extended-reduction instruction.
+/// reduce(ext(...)).
+static VPExtendedReductionRecipe *tryToMatchAndCreateExtendedReduction(
+ const RecurrenceDescriptor &RdxDesc, Instruction *CurrentLinkI,
+ VPValue *PreviousLink, VPValue *VecOp, VPValue *CondOp,
+ LoopVectorizationCostModel &CM, VPCostContext &Ctx, VFRange &Range) {
+ using namespace VPlanPatternMatch;
+
+ VPValue *A;
+ Type *RedTy = RdxDesc.getRecurrenceType();
+
+ // Test if using extended-reduction is beneficial and clamp the range.
+ auto IsExtendedRedValidAndClampRange = [&](unsigned Opcode, bool isZExt,
+ Type *SrcTy) -> bool {
+ return LoopVectorizationPlanner::getDecisionAndClampRange(
+ [&](ElementCount VF) {
+ VectorType *SrcVecTy = cast<VectorType>(ToVectorTy(SrcTy, VF));
+ VectorType *VectorTy = cast<VectorType>(ToVectorTy(RedTy, VF));
----------------
alexey-bataev wrote:
```suggestion
auto *SrcVecTy = cast<VectorType>(ToVectorTy(SrcTy, VF));
auto *VectorTy = cast<VectorType>(ToVectorTy(RedTy, VF));
```
https://github.com/llvm/llvm-project/pull/113903
More information about the llvm-commits
mailing list