@@ -876,38 +876,39 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
876876 VPValue *AnyNaN = nullptr ;
877877 SmallPtrSet<VPValue *, 2 > RdxResults;
878878 for (VPReductionPHIRecipe *RedPhiR : ReductionsToConvert) {
879- assert (RecurrenceDescriptor::isFPMinMaxNumRecurrenceKind (
880- RedPhiR->getRecurrenceKind ()) &&
881- " unsupported reduction" );
879+ assert (RecurrenceDescriptor::isFPMinMaxNumRecurrenceKind (
880+ RedPhiR->getRecurrenceKind ()) &&
881+ " unsupported reduction" );
882882
883- VPValue *MinMaxOp = GetMinMaxCompareValue (RedPhiR);
884- if (!MinMaxOp)
885- return false ;
883+ VPValue *MinMaxOp = GetMinMaxCompareValue (RedPhiR);
884+ if (!MinMaxOp)
885+ return false ;
886886
887- VPValue *IsNaN = Builder.createFCmp (CmpInst::FCMP_UNO, MinMaxOp, MinMaxOp);
888- VPValue *HasNaN = Builder.createNaryOp (VPInstruction::AnyOf, {IsNaN});
889- if (AnyNaN)
890- AnyNaN = Builder.createOr (AnyNaN, HasNaN);
891- else
892- AnyNaN = HasNaN;
893-
894- // If we exit early due to NaNs, compute the final reduction result based
895- // on the reduction phi at the beginning of the last vector iteration.
896- auto *RdxResult = find_singleton<VPSingleDefRecipe>(
897- RedPhiR->getBackedgeValue ()->users (),
898- [RedPhiR](VPUser *U, bool ) -> VPSingleDefRecipe * {
899- auto *VPI = dyn_cast<VPInstruction>(U);
900- if (VPI && VPI->getOpcode () == VPInstruction::ComputeReductionResult)
901- return VPI;
902- assert (U == RedPhiR && " Backedge value must only be used by "
903- " ComputeReductionResult and the reduction phi" );
904- return nullptr ;
905- });
906-
907- auto *NewSel =
908- MiddleBuilder.createSelect (HasNaN, RedPhiR, RdxResult->getOperand (1 ));
909- RdxResult->setOperand (1 , NewSel);
910- RdxResults.insert (RdxResult);
887+ VPValue *IsNaN = Builder.createFCmp (CmpInst::FCMP_UNO, MinMaxOp, MinMaxOp);
888+ VPValue *HasNaN = Builder.createNaryOp (VPInstruction::AnyOf, {IsNaN});
889+ if (AnyNaN)
890+ AnyNaN = Builder.createOr (AnyNaN, HasNaN);
891+ else
892+ AnyNaN = HasNaN;
893+
894+ // If we exit early due to NaNs, compute the final reduction result based
895+ // on the reduction phi at the beginning of the last vector iteration.
896+ auto *RdxResult = find_singleton<VPSingleDefRecipe>(
897+ RedPhiR->getBackedgeValue ()->users (),
898+ [RedPhiR](VPUser *U, bool ) -> VPSingleDefRecipe * {
899+ auto *VPI = dyn_cast<VPInstruction>(U);
900+ if (VPI && VPI->getOpcode () == VPInstruction::ComputeReductionResult)
901+ return VPI;
902+ assert (U == RedPhiR &&
903+ " Backedge value must only be used by "
904+ " ComputeReductionResult and the reduction phi" );
905+ return nullptr ;
906+ });
907+
908+ auto *NewSel =
909+ MiddleBuilder.createSelect (HasNaN, RedPhiR, RdxResult->getOperand (1 ));
910+ RdxResult->setOperand (1 , NewSel);
911+ RdxResults.insert (RdxResult);
911912 }
912913
913914 auto *LatchExitingBranch = LatchVPBB->getTerminator ();
0 commit comments