Fork of llvm with experimental commits and workarounds for RPCS3
Go to file
Keno Fischer 4db92211d7 [ExecutionDepsFix] Improve clearance calculation for loops
Summary:
In revision rL278321, ExecutionDepsFix learned how to pick a better
register for undef register reads, e.g. for instructions such as
`vcvtsi2sdq`. While this revision improved performance on a good number
of our benchmarks, it unfortunately also caused significant regressions
(up to 3x) on others. This regression turned out to be caused by loops
such as:

PH -> A -> B (xmm<Undef> -> xmm<Def>) -> C -> D -> EXIT
      ^                                  |
      +----------------------------------+

In the previous version of the clearance calculation, we would visit
the blocks in order, remembering for each whether there were any
incoming backedges from blocks that we hadn't processed yet and if
so queuing up the block to be re-processed. However, for loop structures
such as the above, this is clearly insufficient, since the block B
does not have any unknown backedges, so we do not see the false
dependency from the previous interation's Def of xmm registers in B.

To fix this, we need to consider all blocks that are part of the loop
and reprocess them one the correct clearance values are known. As
an optimization, we also want to avoid reprocessing any later blocks
that are not part of the loop.

In summary, the iteration order is as follows:
Before: PH A B C D A'
Corrected (Naive): PH A B C D A' B' C' D'
Corrected (w/ optimization): PH A B C A' B' C' D

To facilitate this optimization we introduce two new counters for each
basic block. The first counts how many of it's predecssors have
completed primary processing. The second counts how many of its
predecessors have completed all processing (we will call such a block
*done*. Now, the criteria to reprocess a block is as follows:
    - All Predecessors have completed primary processing
    - For x the number of predecessors that have completed primary
      processing *at the time of primary processing of this block*,
      the number of predecessors that are done has reached x.

The intuition behind this criterion is as follows:
We need to perform primary processing on all predecessors in order to
find out any direct defs in those predecessors. When predecessors are
done, we also know that we have information about indirect defs (e.g.
in block B though that were inherited through B->C->A->B). However,
we can't wait for all predecessors to be done, since that would
cause cyclic dependencies. However, it is guaranteed that all those
predecessors that are prior to us in reverse postorder will be done
before us. Since we iterate of the basic blocks in reverse postorder,
the number x above, is precisely the count of the number of predecessors
prior to us in reverse postorder.

Reviewers: myatsina
Differential Revision: https://reviews.llvm.org/D28759

llvm-svn: 293571
2017-01-30 23:37:03 +00:00
bindings Fix go bindings after r289702 (hopefully, don't really know how to build 2016-12-15 06:54:29 +00:00
cmake CMake is funky on detecting Intel 17 as GCC compatible. 2017-01-26 23:50:18 +00:00
docs [LanRef] Fix typo in getelementptr example. 2017-01-30 07:38:58 +00:00
examples Use print() instead of dump() in code 2017-01-28 02:47:46 +00:00
include [WebAssembly] Add wasm support for llvm-readobj 2017-01-30 23:30:52 +00:00
lib [ExecutionDepsFix] Improve clearance calculation for loops 2017-01-30 23:37:03 +00:00
projects
resources
runtimes [CMake] Handle common options for runtimes build 2017-01-10 19:47:05 +00:00
test [ExecutionDepsFix] Improve clearance calculation for loops 2017-01-30 23:37:03 +00:00
tools [WebAssembly] Add wasm support for llvm-readobj 2017-01-30 23:30:52 +00:00
unittests Revert "[MemorySSA] Revert r293361 and r293363, as the tests fail under asan." 2017-01-30 11:35:39 +00:00
utils Fix the GCC build. 2017-01-30 19:05:09 +00:00
.arcconfig
.clang-format
.clang-tidy
.gitignore [AVR] Add the integrated testing tool to the .gitignore 2016-12-14 11:47:14 +00:00
CMakeLists.txt This addresses LLDB bug 31699, which was caused by LLVM using static linking on Windows. 2017-01-28 07:39:52 +00:00
CODE_OWNERS.TXT CODE_OWNERS: Take ownership of IR Linker as discussed on llvm-dev 2016-12-02 14:06:53 +00:00
configure
CREDITS.TXT Revert revision 289721. 2016-12-14 21:58:42 +00:00
LICENSE.TXT Bump year to 2017 in LICENSE.txt 2017-01-12 18:02:42 +00:00
llvm.spec.in
LLVMBuild.txt
README.txt Test commit. 2017-01-27 23:59:26 +00:00
RELEASE_TESTERS.TXT Update the release tester for MIPS. NFC. 2017-01-17 11:00:28 +00:00

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.