@@ -9171,6 +9171,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
91719171 if (CM.blockNeedsPredicationForAnyReason (CurrentLinkI->getParent ()))
91729172 CondOp = RecipeBuilder.getBlockInMask (CurrentLink->getParent ());
91739173
9174+ // TODO: Retrieve FMFs from recipes directly.
91749175 RecurrenceDescriptor RdxDesc = Legal->getRecurrenceDescriptor (
91759176 cast<PHINode>(PhiR->getUnderlyingInstr ()));
91769177 // Non-FP RdxDescs will have all fast math flags set, so clear them.
@@ -9252,24 +9253,23 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92529253 VPInstruction *FinalReductionResult;
92539254 VPBuilder::InsertPointGuard Guard (Builder);
92549255 Builder.setInsertPoint (MiddleVPBB, IP);
9255- if ( RecurrenceDescriptor::isFindIVRecurrenceKind (
9256- RdxDesc. getRecurrenceKind () )) {
9256+ RecurKind RecurrenceKind = PhiR-> getRecurrenceKind ();
9257+ if ( RecurrenceDescriptor::isFindIVRecurrenceKind (RecurrenceKind )) {
92579258 VPValue *Start = PhiR->getStartValue ();
92589259 VPValue *Sentinel = Plan->getOrAddLiveIn (RdxDesc.getSentinelValue ());
92599260 FinalReductionResult =
92609261 Builder.createNaryOp (VPInstruction::ComputeFindIVResult,
92619262 {PhiR, Start, Sentinel, NewExitingVPV}, ExitDL);
9262- } else if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
9263- RdxDesc.getRecurrenceKind ())) {
9263+ } else if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RecurrenceKind)) {
92649264 VPValue *Start = PhiR->getStartValue ();
92659265 FinalReductionResult =
92669266 Builder.createNaryOp (VPInstruction::ComputeAnyOfResult,
92679267 {PhiR, Start, NewExitingVPV}, ExitDL);
92689268 } else {
9269- VPIRFlags Flags = RecurrenceDescriptor::isFloatingPointRecurrenceKind (
9270- RdxDesc. getRecurrenceKind () )
9271- ? VPIRFlags (RdxDesc.getFastMathFlags ())
9272- : VPIRFlags ();
9269+ VPIRFlags Flags =
9270+ RecurrenceDescriptor::isFloatingPointRecurrenceKind (RecurrenceKind )
9271+ ? VPIRFlags (RdxDesc.getFastMathFlags ())
9272+ : VPIRFlags ();
92739273 FinalReductionResult =
92749274 Builder.createNaryOp (VPInstruction::ComputeReductionResult,
92759275 {PhiR, NewExitingVPV}, Flags, ExitDL);
@@ -9278,11 +9278,9 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
92789278 // then extend the loop exit value to enable InstCombine to evaluate the
92799279 // entire expression in the smaller type.
92809280 if (MinVF.isVector () && PhiTy != RdxDesc.getRecurrenceType () &&
9281- !RecurrenceDescriptor::isAnyOfRecurrenceKind (
9282- RdxDesc.getRecurrenceKind ())) {
9281+ !RecurrenceDescriptor::isAnyOfRecurrenceKind (RecurrenceKind)) {
92839282 assert (!PhiR->isInLoop () && " Unexpected truncated inloop reduction!" );
9284- assert (!RecurrenceDescriptor::isMinMaxRecurrenceKind (
9285- RdxDesc.getRecurrenceKind ()) &&
9283+ assert (!RecurrenceDescriptor::isMinMaxRecurrenceKind (RecurrenceKind) &&
92869284 " Unexpected truncated min-max recurrence!" );
92879285 Type *RdxTy = RdxDesc.getRecurrenceType ();
92889286 auto *Trunc =
@@ -9318,8 +9316,7 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
93189316 // with a boolean reduction phi node to check if the condition is true in
93199317 // any iteration. The final value is selected by the final
93209318 // ComputeReductionResult.
9321- if (RecurrenceDescriptor::isAnyOfRecurrenceKind (
9322- RdxDesc.getRecurrenceKind ())) {
9319+ if (RecurrenceDescriptor::isAnyOfRecurrenceKind (RecurrenceKind)) {
93239320 auto *Select = cast<VPRecipeBase>(*find_if (PhiR->users (), [](VPUser *U) {
93249321 return isa<VPWidenSelectRecipe>(U) ||
93259322 (isa<VPReplicateRecipe>(U) &&
0 commit comments