Skip to content

Commit 48fb470

Browse files
committed
[IVDesc] More comment updates from review
1 parent a4c31c8 commit 48fb470

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

llvm/lib/Analysis/IVDescriptors.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

llvm/test/Transforms/LoopVectorize/iv-select-cmp-decreasing.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ exit: ; preds = %loop
11421142

11431143
; The unsigned sentinel value for decreasing-IV vectorization is ULONG_MAX,
11441144
; and since the IV hits this value, it is impossible to vectorize this case.
1145-
; This test includes both signed and unsigned sentinel values.
1145+
; In this test, %iv's range will include both signed and unsigned
1146+
; maximum (sentinel) values.
11461147
define i64 @not_vectorized_select_decreasing_induction_icmp_iv_out_of_bound(ptr %a, ptr %b, i64 %rdx.start) {
11471148
; CHECK-LABEL: define i64 @not_vectorized_select_decreasing_induction_icmp_iv_out_of_bound(
11481149
; CHECK-SAME: ptr [[A:%.*]], ptr [[B:%.*]], i64 [[RDX_START:%.*]]) {

0 commit comments

Comments
 (0)