Go to file
Hal Finkel 25c1992bc7 Implement PPC counter loops as a late IR-level pass
The old PPCCTRLoops pass, like the Hexagon pass version from which it was
derived, could only handle some simple loops in canonical form. We cannot
directly adapt the new Hexagon hardware loops pass, however, because the
Hexagon pass contains a fundamental assumption that non-constant-trip-count
loops will contain a guard, and this is not always true (the result being that
incorrect negative counts can be generated). With this commit, we replace the
pass with a late IR-level pass which makes use of SE to calculate the
backedge-taken counts and safely generate the loop-count expressions (including
any necessary max() parts). This IR level pass inserts custom intrinsics that
are lowered into the desired decrement-and-branch instructions.

The most fragile part of this new implementation is that interfering uses of
the counter register must be detected on the IR level (and, on PPC, this also
includes any indirect branches in addition to function calls). Also, to make
all of this work, we need a variant of the mtctr instruction that is marked
as having side effects. Without this, machine-code level CSE, DCE, etc.
illegally transform the resulting code. Hopefully, this can be improved
in the future.

This new pass is smaller than the original (and much smaller than the new
Hexagon hardware loops pass), and can handle many additional cases correctly.
In addition, the preheader-creation code has been copied from LoopSimplify, and
after we decide on where it belongs, this code will be refactored so that it
can be explicitly shared (making this implementation even smaller).

The new test-case files ctrloop-{le,lt,ne}.ll have been adapted from tests for
the new Hexagon pass. There are a few classes of loops that this pass does not
transform (noted by FIXMEs in the files), but these deficiencies can be
addressed within the SE infrastructure (thus helping many other passes as well).

llvm-svn: 181927
2013-05-15 21:37:41 +00:00
clang Test commit 2013-05-15 19:49:05 +00:00
clang-tools-extra cpp11-migrate: Add override specifier before comments on inline methods 2013-05-14 17:34:12 +00:00
compiler-rt Try to improve performance by using a read/write buffer instead of I/O. 2013-05-15 21:31:22 +00:00
debuginfo-tests Remove IR scenario tests. 2013-03-15 20:52:10 +00:00
libclc Update the copyright coredits -- Happy new year 2013! 2013-01-01 10:00:19 +00:00
libcxx Fixing the MSan/compiler-rt build 2013-05-13 21:53:44 +00:00
libcxxabi Add capability to demangle invocation functions for ObjC blocks. 2013-04-10 19:44:03 +00:00
lld [lld] Fix compiler warning that shift count is too big on P64. 2013-05-14 23:51:50 +00:00
lldb Fixed an xpass due to r181841 on Linux with gcc. Note that the clang variant contains to xfail, and r181841 is a fix for the test. 2013-05-15 20:26:30 +00:00
llvm Implement PPC counter loops as a late IR-level pass 2013-05-15 21:37:41 +00:00
polly Sort includes 2013-05-07 08:11:54 +00:00