[llvm] [VPlan] Optimize FindLast of FindIV w/o sentinel. (PR #172569)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 00:49:30 PST 2026
================
@@ -5526,36 +5526,83 @@ void VPlanTransforms::optimizeFindIVReductions(VPlan &Plan,
CheckSentinel(IVSCEV, UseMax, /*IsSigned=*/true);
if (!SentinelVal) {
SentinelVal = CheckSentinel(IVSCEV, UseMax, /*IsSigned=*/false);
- if (!SentinelVal)
- continue;
UseSigned = false;
}
- auto *RdxResult = cast<VPInstruction>(vputils::findRecipe(
+ // Fall back to boolean tracking if IV doesn't wrap.
+ if (!SentinelVal) {
+ auto *AR = cast<SCEVAddRecExpr>(IVSCEV);
+ if (AR->hasNoSignedWrap()) {
+ UseSigned = true;
+ } else if (AR->hasNoUnsignedWrap()) {
+ UseSigned = false;
+ } else {
+ continue;
+ }
----------------
Mel-Chen wrote:
```suggestion
if (AR->hasNoSignedWrap())
UseSigned = true;
else if (AR->hasNoUnsignedWrap())
UseSigned = false;
else
continue;
```
https://github.com/llvm/llvm-project/pull/172569
More information about the llvm-commits
mailing list