[llvm] [LV] Extend FindFirstIV to unsigned case (PR #146386)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 3 13:43:15 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);
----------------
fhahn wrote:
The reason this works I think is that Start > End, so it's a wrapped range. Relying on this makes the code ability bit harder to read/follow, so it may be better to keep the original structure and explicitly set the start to the minimum value and the end to Sentinel - 1, even if it is not as compact.
https://github.com/llvm/llvm-project/pull/146386
More information about the llvm-commits
mailing list