[PATCH] D60565: [LOOPINFO] Extend Loop object to add utilities to get the loop bounds, step, induction variable, and guard branch.
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 13 18:23:18 PDT 2019
jdoerfert added inline comments.
================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:418
+ return GuardBI;
+ }
+
----------------
kbarton wrote:
> In the comments you describe the guard in terms of dominance, but you don't use dominance anywhere in the function.
>
> I would suggest trying to refactor this as follows:
>
> Change this method to getPotentialGuardBlock, that returns the basic block that (potentially) guards the loop body.
> I think you can determine the guard block using dominators and post-dominators. Specifically, the guard block should be the closest predecessor that dominates the loop preheader. And the "other" successor of the potential guard block should post-dominate all of the blocks inside the loop. I believe that should be sufficient to guarantee the block is a potential guard.
>
> Then you can get the branch from the guard block in the getGuard method, and do the necessary analysis on the branch itself to verify it conforms with the requirements for a guard branch. Does this make sense?
> And the "other" successor of the potential guard block should post-dominate all of the blocks inside the loop.
Not all blocks but just the header I think. That should allow multi-exit loops (if it matters).
> I believe that should be sufficient to guarantee the block is a potential guard.
Agreed.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60565/new/
https://reviews.llvm.org/D60565
More information about the llvm-commits
mailing list