[PATCH] D109354: [LoopBoundSplit] Check the split condition with its AddRec start value
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 23:45:20 PDT 2021
mkazantsev requested changes to this revision.
mkazantsev added inline comments.
This revision now requires changes to proceed.
================
Comment at: llvm/lib/Transforms/Scalar/LoopBoundSplit.cpp:273
+ const SCEV *SplitAddRecStartSCEV =
+ dyn_cast<SCEVAddRecExpr>(SplitCandidateCond.AddRecSCEV)->getStart();
+ if (SE.isKnownPredicate(
----------------
This should either be `cast` instead of `dyn_cast` (if it never fails), or there should be a null check (if it may fail).
================
Comment at: llvm/lib/Transforms/Scalar/LoopBoundSplit.cpp:274
+ dyn_cast<SCEVAddRecExpr>(SplitCandidateCond.AddRecSCEV)->getStart();
+ if (SE.isKnownPredicate(
+ ICmpInst::getInversePredicate(SplitCandidateCond.Pred),
----------------
And what if both direct and inverted predicates are not known? It may be false, but SCEV is just not smart enough to prove it.
I think the correct (conservative) check should be like
```
if (!isKnownPredicate(SplitCandidateCond.Pred, SplitAddRecStartSCEV, SplitCandidateCond.BoundSCEV))
continue;
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109354/new/
https://reviews.llvm.org/D109354
More information about the llvm-commits
mailing list