@@ -676,12 +676,15 @@ RecurrenceDescriptor::isAnyOfPattern(Loop *Loop, PHINode *OrigPhi,
676676// %inc = add nsw i32 %i, 1
677677// ...
678678// Since 'i' is an induction variable, the reduction value after the loop will
679- // be the maximum value of 'i' that the condition (src[i] > 3) is satisfied, or
680- // the start value (0 in the example above). When the start value of the
681- // induction variable 'i' is greater than the minimum value of the data type, we
682- // can use the minimum value of the data type as a sentinel value to replace the
683- // start value. This allows us to perform a single reduction max operation to
684- // obtain the final reduction result.
679+ // be the maximum (increasing induction) or minimum (decreasing induction) value
680+ // of 'i' that the condition (src[i] > 3) is satisfied, or the start value (0 in
681+ // the example above). When the start value of the induction variable 'i' is
682+ // greater than the minimum (increasing induction) or maximum (decreasing
683+ // induction) value of the data type, we can use the minimum (increasing
684+ // induction) or maximum (decreasing induction) value of the data type as a
685+ // sentinel value to replace the start value. This allows us to perform a single
686+ // reduction max (increasing induction) or min (decreasing induction) operation
687+ // to obtain the final reduction result.
685688// TODO: It is possible to solve the case where the start value is the minimum
686689// value of the data type or a non-constant value by using mask and multiple
687690// reduction operations.
@@ -723,12 +726,12 @@ RecurrenceDescriptor::isFindIVPattern(RecurKind Kind, Loop *TheLoop,
723726 (isFindLastIVRecurrenceKind (Kind) && !SE.isKnownPositive (Step)))
724727 return std::nullopt ;
725728
726- // Keep the minimum (FindLast) or maximum (FindFirst) value of the
727- // recurrence type as the sentinel value. The maximum acceptable range for
728- // the induction variable, called the valid range will exclude <sentinel
729- // value>, where <sentinel value> is [Signed|Unsigned]Min(<recurrence type>)
730- // for FindLastIV or [Signed|Unsigned]Max (<recurrence type>) for
731- // FindFirstIV.
729+ // Check if the minimum (FindLast) or maximum (FindFirst) value of the
730+ // recurrence type can be used as a sentinel value. The maximum acceptable
731+ // range for the induction variable, called the valid range will exclude
732+ // <sentinel value>, where <sentinel value> is
733+ // [Signed|Unsigned]Min (<recurrence type>) for FindLastIV or
734+ // [Signed|Unsigned]Max(<recurrence type>) for FindFirstIV.
732735 // TODO: This range restriction can be lifted by adding an additional
733736 // virtual OR reduction.
734737 auto CheckRange = [&](bool IsSigned) {
0 commit comments