OSDN Git Service

[PM/Unswitch] Fix a bug in the domtree update logic for the new unswitch
authorChandler Carruth <chandlerc@gmail.com>
Thu, 25 May 2017 06:33:36 +0000 (06:33 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 25 May 2017 06:33:36 +0000 (06:33 +0000)
commit2dcd120478d144853e24587ebad633e178dfae8c
tree5b0e05b49f83e304bdee92c500a1718c7fa2b4e2
parentba01932aa0fec3609ebc084f0b4d6bd55b10283b
[PM/Unswitch] Fix a bug in the domtree update logic for the new unswitch
pass.

The original logic only considered direct successors of the hoisted
domtree nodes, but that isn't really enough. If there are other basic
blocks that are completely within the subtree, their successors could
just as easily be impacted by the hoisting.

The more I think about it, the more I think the correct update here is
to hoist every block on the dominance frontier which has an idom in the
chain we hoist across. However, this is subtle enough that I'd
definitely appreciate some more eyes on it.

Sadly, if this is the correct algorithm, it requires computing a (highly
localized) dominance frontier. I've done this in the simplest (IE, least
code) way I could come up with, but that may be too naive. Suggestions
welcome here, dominance update algorithms are not an area I've studied
much, so I don't have strong opinions.

In good news, with this patch, turning on simple unswitch passes the
LLVM test suite for me with asserts enabled.

Differential Revision: https://reviews.llvm.org/D32740

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303843 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
test/Transforms/SimpleLoopUnswitch/trivial-unswitch.ll