[llvm] [LV] Extend FindFirstIV to unsigned case (PR #146386)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 06:19:10 PDT 2025
================
@@ -741,10 +742,9 @@ RecurrenceDescriptor::isFindIVPattern(RecurKind Kind, Loop *TheLoop,
: APInt::getMinValue(NumBits);
ValidRange = ConstantRange::getNonEmpty(Sentinel + 1, Sentinel);
} else {
- assert(IsSigned && "Only FindFirstIV with SMax is supported currently");
- ValidRange =
- ConstantRange::getNonEmpty(APInt::getSignedMinValue(NumBits),
- APInt::getSignedMaxValue(NumBits) - 1);
+ APInt Sentinel = IsSigned ? APInt::getSignedMaxValue(NumBits)
+ : APInt::getMaxValue(NumBits);
+ ValidRange = ConstantRange::getNonEmpty(Sentinel, Sentinel - 1);
----------------
david-arm wrote:
Is this right? I thought the point of the range was to exclude everything except the sentinel, but if I've understood ConstantRange::getNonEmpty correctly it creates the range [Lower, Upper) where in this case Lower == Sentinel. This means Sentinel is included in the range? This seems to contradict the findlastiv case where we create the range [Sentinel + 1, Sentinel)
https://github.com/llvm/llvm-project/pull/146386
More information about the llvm-commits
mailing list