[PATCH] D40874: [LV][LoopInfo] Add irreducible CFG detection for outer loops

Diego Caballero via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 15:24:22 PST 2018


dcaballe updated this revision to Diff 129171.
dcaballe added a comment.

The refactoring of a generic utility function to detect irreducible CFG required a little more work because the other user, ShrinkWrap (https://reviews.llvm.org/D41886), needed this functionality at Function level and not at Loop level as we need it in LV. This new patch adds such a utility function which works on any CFG given its RPO traversal and its LoopInfoBase. This function is a generalization of ‘isIrreducibleCFG’ in lib/CodeGen/ShrinkWrap.cpp. It should be generic enough to deal with any CFG in LLVM that is supported by LoopInfoBase. RPO traversal is a function parameter which would allow to reuse RPO traversals that were previously computed for other purposes.

If you are OK with this approach, there are two questions that should be discussed as part of the review:

1. Location of this utility function: I placed this function in include/llvm/Analysis/CFG.h. I would be happy to move it somewhere else if you think it’s more appropriate.
2. Removing or preserving existing SCC-based ‘hasCyclesInLoopBody’ function for inner loop cases:  Since the new generic utility function works for inner and outer loops, I think that ‘hasCyclesInLoopBody’ is no longer necessary. I think that computing and traversing the SCCs of an inner loop body without back-edges (1 SCC per BasicBlock) is, at least, as expensive in practice as computing and traversing the inner loop body in RPO. I measured the compile time of both approaches in a couple of benchmarks suites and I couldn’t observe any performance difference.

https://reviews.llvm.org/D41886 updates ShrinkWrap to use this generic utility function.

Please, let me know what you think.
Thanks,
Diego.


https://reviews.llvm.org/D40874

Files:
  include/llvm/Analysis/CFG.h
  include/llvm/Analysis/LoopIterator.h
  lib/Transforms/Vectorize/LoopVectorize.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40874.129171.patch
Type: text/x-patch
Size: 5396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180109/4ee06d9e/attachment.bin>


More information about the llvm-commits mailing list