This is an archive of the discontinued LLVM Phabricator instance.

[Loop Peeling] Fix idom detection algorithm
ClosedPublic

Authored by skatkov on Jul 25 2019, 10:32 AM.

Details

Summary

We'd like to determine the idom of exit block after peeling one iteration.
Let Exit is exit block.
Let ExitingSet - is a set of predecessors of Exit block. They are exiting blocks.
Let Latch' and ExitingSet' are copies after a peeling.
We'd like to find an idom'(Exit) - idom of Exit after peeling.
It is an evident that idom'(Exit) will be the nearest common dominator of ExitingSet and ExitingSet'.
idom(Exit) is a nearest common dominator of ExitingSet.
idom(Exit)' is a nearest common dominator of ExitingSet'.
Taking into account that we have a single Latch, Latch' will dominate Header and idom(Exit).
So the idom'(Exit) is nearest common dominator of idom(Exit)' and Latch'.
All these basic blocks are in the same loop, so what we find is
(nearest common dominator of idom(Exit) and Latch)'.

Diff Detail

Event Timeline

skatkov created this revision.Jul 25 2019, 10:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2019, 10:32 AM
fhahn added inline comments.Jul 25 2019, 10:55 AM
llvm/test/Transforms/LoopUnroll/peel-loop-pgo-deopt-idom-2.ll
2

I *think* if you pass -verify-dom-info, you do not require asserts for the assertion in LoopUnrollPeel.cpp:735. It will verify the DT after unrolling/peeling, which should be sufficient.

fhahn added inline comments.Jul 25 2019, 10:59 AM
llvm/test/Transforms/LoopUnroll/peel-loop-pgo-deopt-idom-2.ll
2

ah you check the debug output, never mind.

skatkov marked an inline comment as done.Jul 25 2019, 11:07 AM
skatkov added inline comments.
llvm/test/Transforms/LoopUnroll/peel-loop-pgo-deopt-idom-2.ll
2

I need
; REQUIRES: asserts
for --debug-only

This revision was not accepted when it landed; it landed in state Needs Review.Jul 25 2019, 12:32 PM
This revision was automatically updated to reflect the committed changes.