Go to file
Keno Fischer 578cf7aae7 [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
clang PR28739: Check that integer values fit into 64 bits before extracting them as 64 bit values for pointer arithmetic. 2017-01-30 23:30:26 +00:00
clang-tools-extra Revert "Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications." 2017-01-27 07:19:22 +00:00
compiler-rt [sanitizer] Re-enable -fno-function-sections for powerpc64le 2017-01-30 22:31:49 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc math: Add logb builtin 2017-01-18 03:14:10 +00:00
libcxx experimental: avoid using raw _WIN32 in filesystem 2017-01-30 19:57:27 +00:00
libcxxabi Fix ASAN failure in cxa_demangle 2017-01-27 20:32:16 +00:00
libunwind Revert "DWARF: convert error logs to _LIBUNWIND_LOG" 2017-01-27 02:26:52 +00:00
lld Add missing aarch64 requirement. 2017-01-30 18:49:38 +00:00
lldb Switch HostInfoNetBSD::GetProgramFileSpec to sysctl(7) 2017-01-28 20:04:53 +00:00
llgo [llgo] Remove support for LLVM attributes 2016-12-06 19:22:04 +00:00
llvm [ExecutionDepsFix] Improve clearance calculation for loops 2017-01-30 23:37:03 +00:00
openmp Correct wrong comment in bug_nested_proxy_task.c 2017-01-30 09:51:02 +00:00
parallel-libs [Axccel] Remove -Wno-missing-braces in build 2016-12-19 21:34:07 +00:00
polly Update the documentation on how the packing transformation is implemented 2017-01-29 10:37:50 +00:00