[PATCH] D48851: [PM/LoopUnswitch] Fix the first and immediate components of PR37889.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 14:40:40 PDT 2018


chandlerc created this revision.
chandlerc added reviewers: sanjoy, asbirlea.
Herald added subscribers: hiraditya, mcrosier.

This PR illustrates that a fundamental analysis update was not performed
with the new loop unswitch. This update is also somewhat fundamental to
the core idea of the new loop unswitch -- we actually *update* the CFG
based on the unswitching. In order to do that, we need to update the
loop nest in addition to the domtree.

For some reason, when writing trivial unswitching, I thought that the
loop nest structure cannot be changed by the transformation. But the PR
helps illustrate that it clearly can. I've expanded this to a number of
different test cases that try to cover the different cases of this. When
we unswitch, we move an exit edge of a loop out of the loop. If this
exit edge changes which loop reached by an exit is the innermost loop,
it changes the parent of the loop. Essentially, this transformation may
hoist the inner loop up the nest.

I've added the simple logic to handle this reliably in the trivial
unswitching case. However, in the non-trivial case we have a harder
problem because we may be creating new sibling loops. I'm going to port
these test cases over to it to see if it too is missing some handling
for the hoisting, but the logic to implement it will likely need to be
a bit different, and similar to the logic we already use to hoist the
newly created sibling loops. Due to these differences, I'm sending this
out as a separate patch and then I'll send a follow-up that at least
adds test coverage and maybe adds the necessary logic, re-using what
I've added here if I see a good way to do that.


Repository:
  rL LLVM

https://reviews.llvm.org/D48851

Files:
  llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/trivial-unswitch.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48851.153802.patch
Type: text/x-patch
Size: 13996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/22a1156c/attachment.bin>


More information about the llvm-commits mailing list