[PATCH] D109354: [LoopBoundSplit] Check the start value of split cond AddRec

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 12 20:11:41 PDT 2021


mkazantsev accepted this revision.
mkazantsev added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



================
Comment at: llvm/lib/Transforms/Scalar/LoopBoundSplit.cpp:272
+    const SCEV *SplitAddRecStartSCEV =
+        cast<SCEVAddRecExpr>(SplitCandidateCond.AddRecSCEV)->getStart();
+    if (!SE.isKnownPredicate(SplitCandidateCond.Pred, SplitAddRecStartSCEV,
----------------
As a follow-up (no need to do it in this patch): can AddRecSCEV have the type of `SCEVAddRecExpr` so that this cast is not needed?


================
Comment at: llvm/lib/Transforms/Scalar/LoopBoundSplit.cpp:273
+    const SCEV *SplitAddRecStartSCEV =
+        dyn_cast<SCEVAddRecExpr>(SplitCandidateCond.AddRecSCEV)->getStart();
+    if (SE.isKnownPredicate(
----------------
jaykang10 wrote:
> mkazantsev wrote:
> > This should either be `cast` instead of `dyn_cast` (if it never fails), or there should be a null check (if it may fail).
> Sorry, let me update it with cast.
As a follow-up: consider using `isLoopEntryGuardedByCond`. Maybe the 1st iter condition can be inferred from a guarding check. Can be a separate patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109354/new/

https://reviews.llvm.org/D109354



More information about the llvm-commits mailing list