Chris Lattner
0caf28f4ff
Move loop optimization passes up, add loop unroller
...
llvm-svn: 13030
2004-04-18 05:21:01 +00:00
Chris Lattner
27fd823c1b
Add prototype
...
llvm-svn: 13029
2004-04-18 05:20:32 +00:00
Chris Lattner
b0d23bf99d
Initial checkin of a simple loop unroller. This pass is extremely basic and
...
limited. Even in it's extremely simple state (it can only *fully* unroll single
basic block loops that execute a constant number of times), it already helps improve
performance a LOT on some benchmarks, particularly with the native code generators.
llvm-svn: 13028
2004-04-18 05:20:17 +00:00
Chris Lattner
e0f56972f0
Make the tail duplication threshold accessible from the command line instead of hardcoded
...
llvm-svn: 13025
2004-04-18 00:52:43 +00:00
Chris Lattner
22ca3df5b1
Fix a memory leak. We leaked the vector holding the entries in switch tables.
...
llvm-svn: 13023
2004-04-17 23:49:15 +00:00
Chris Lattner
7a6db7ee0e
New testcase
...
llvm-svn: 13020
2004-04-17 23:00:51 +00:00
Chris Lattner
b5ee2bcb62
Add the ability to compute exit values for complex loop using unanalyzable
...
operations. This allows us to compile this testcase:
int main() {
int h = 1;
do h = 3 * h + 1; while (h <= 256);
printf("%d\n", h);
return 0;
}
into this:
int %main() {
entry:
call void %__main( )
%tmp.6 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([4 x sbyte]* %.str_1, long 0, long 0), int 364 ) ; <int> [#uses=0]
ret int 0
}
This testcase was taken directly from 256.bzip2, believe it or not.
This code is not as general as I would like. Next up is to refactor it
a bit to handle more cases.
llvm-svn: 13019
2004-04-17 22:58:41 +00:00
Chris Lattner
740ae78ae6
If the loop executes a constant number of times, try a bit harder to replace
...
exit values.
llvm-svn: 13018
2004-04-17 18:44:09 +00:00
Chris Lattner
9a73de2ba2
Add the ability to compute trip counts that are only controlled by constants
...
even if the loop is using expressions that we can't compute as a closed-form.
This allows us to calculate that this function always returns 55:
int test() {
double X;
int Count = 0;
for (X = 100; X > 1; X = sqrt(X), ++Count)
/*empty*/;
return Count;
}
And allows us to compute trip counts for loops like:
int h = 1;
do h = 3 * h + 1; while (h <= 256);
(which occurs in bzip2), and for this function, which occurs after inlining
and other optimizations:
int popcount()
{
int x = 666;
int result = 0;
while (x != 0) {
result = result + (x & 0x1);
x = x >> 1;
}
return result;
}
We still cannot compute the exit values of result or h in the two loops above,
which means we cannot delete the loop, but we are getting closer. Being able to
compute a constant trip count for these two loops will allow us to unroll them
completely though.
llvm-svn: 13017
2004-04-17 18:36:24 +00:00
Chris Lattner
bcb690dc9b
Fix a HUGE pessimization on X86. The indvars pass was taking this
...
(familiar) function:
int _strlen(const char *str) {
int len = 0;
while (*str++) len++;
return len;
}
And transforming it to use a ulong induction variable, because the type of
the pointer index was left as a constant long. This is obviously very bad.
The fix is to shrink long constants in getelementptr instructions to intptr_t,
making the indvars pass insert a uint induction variable, which is much more
efficient.
Here's the before code for this function:
int %_strlen(sbyte* %str) {
entry:
%tmp.13 = load sbyte* %str ; <sbyte> [#uses=1]
%tmp.24 = seteq sbyte %tmp.13, 0 ; <bool> [#uses=1]
br bool %tmp.24, label %loopexit, label %no_exit
no_exit: ; preds = %entry, %no_exit
*** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=2]
*** %indvar = phi ulong [ %indvar.next, %no_exit ], [ 0, %entry ] ; <ulong> [#uses=2]
%indvar1 = cast ulong %indvar to uint ; <uint> [#uses=1]
%inc.02.sum = add uint %indvar1, 1 ; <uint> [#uses=1]
%inc.0.0 = getelementptr sbyte* %str, uint %inc.02.sum ; <sbyte*> [#uses=1]
%tmp.1 = load sbyte* %inc.0.0 ; <sbyte> [#uses=1]
%tmp.2 = seteq sbyte %tmp.1, 0 ; <bool> [#uses=1]
%indvar.next = add ulong %indvar, 1 ; <ulong> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %loopexit.loopexit, label %no_exit
loopexit.loopexit: ; preds = %no_exit
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%inc.1 = add int %indvar, 1 ; <int> [#uses=1]
ret int %inc.1
loopexit: ; preds = %entry
ret int 0
}
Here's the after code:
int %_strlen(sbyte* %str) {
entry:
%inc.02 = getelementptr sbyte* %str, uint 1 ; <sbyte*> [#uses=1]
%tmp.13 = load sbyte* %str ; <sbyte> [#uses=1]
%tmp.24 = seteq sbyte %tmp.13, 0 ; <bool> [#uses=1]
br bool %tmp.24, label %loopexit, label %no_exit
no_exit: ; preds = %entry, %no_exit
*** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; <uint> [#uses=3]
%indvar = cast uint %indvar to int ; <int> [#uses=1]
%inc.0.0 = getelementptr sbyte* %inc.02, uint %indvar ; <sbyte*> [#uses=1]
%inc.1 = add int %indvar, 1 ; <int> [#uses=1]
%tmp.1 = load sbyte* %inc.0.0 ; <sbyte> [#uses=1]
%tmp.2 = seteq sbyte %tmp.1, 0 ; <bool> [#uses=1]
%indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
br bool %tmp.2, label %loopexit, label %no_exit
loopexit: ; preds = %entry, %no_exit
%len.0.1 = phi int [ 0, %entry ], [ %inc.1, %no_exit ] ; <int> [#uses=1]
ret int %len.0.1
}
llvm-svn: 13016
2004-04-17 18:16:10 +00:00
Chris Lattner
5c85946417
Even if there are not any induction variables in the loop, if we can compute
...
the trip count for the loop, insert one so that we can canonicalize the exit
condition.
llvm-svn: 13015
2004-04-17 18:08:33 +00:00
Chris Lattner
6d5decd7d4
Add support for evaluation of exp/log/log10/pow
...
llvm-svn: 13011
2004-04-16 22:35:33 +00:00
Chris Lattner
ed423cc09d
Fix some really nasty dominance bugs that were exposed by my patch to
...
make the verifier more strict. This fixes building zlib
llvm-svn: 13002
2004-04-16 18:08:07 +00:00
Misha Brukman
cb5de6bca6
Fix retriving parent Function.
...
llvm-svn: 13001
2004-04-16 17:37:12 +00:00
Misha Brukman
a2cc39ff28
Fit comment into 80 cols.
...
llvm-svn: 12996
2004-04-16 17:13:52 +00:00
Brian Gaeke
decd864ee4
Regenerated using autoconf-2.57.
...
llvm-svn: 12995
2004-04-16 17:13:44 +00:00
Brian Gaeke
66f747098a
Refactor external benchmark checking stuff into one hairy
...
macro-to-bind-them-all, called EXTERNAL_BENCHMARK().
llvm-svn: 12994
2004-04-16 17:13:33 +00:00
Misha Brukman
52a9e3b31f
Add idea about a disassembler.
...
llvm-svn: 12993
2004-04-16 16:55:30 +00:00
Brian Gaeke
76f386fd75
Switch to including <iostream> for compatibility with gcc-3.0.x (Debian).
...
llvm-svn: 12990
2004-04-16 16:28:33 +00:00
Misha Brukman
fdb346f70a
* Fix capitalization of PICk
...
* Wrap long lines to 80 cols
llvm-svn: 12988
2004-04-16 16:20:07 +00:00
Brian Gaeke
4b9f67c638
Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
...
Debian.)
llvm-svn: 12986
2004-04-16 15:57:32 +00:00
Brian Gaeke
2a087ad673
Include <string> for compatibility with gcc 3.0.x (the system compiler on
...
Debian.)
llvm-svn: 12985
2004-04-16 15:57:14 +00:00
Brian Gaeke
c465066a6c
As a part of the bootstrapping process, the top-level tools-only target
...
should not build projects.
llvm-svn: 12984
2004-04-16 15:57:02 +00:00
Misha Brukman
aadcd46d25
Assert if deleting BasicBlock before removing it from Function.
...
llvm-svn: 12983
2004-04-16 15:47:21 +00:00
Misha Brukman
7c46021fe7
Assert if Instruction is being deleted before being removed from BasicBlock.
...
llvm-svn: 12982
2004-04-16 15:46:43 +00:00
Chris Lattner
a6f2680e2d
Remove libraries that have no reason to be here, and keep breaking the nightly tester because their makefiles do not have the right dependencies!!
...
llvm-svn: 12981
2004-04-16 14:12:36 +00:00
Chris Lattner
bc458be5f9
Fix some of the strange CBE-only failures that happened last night.
...
llvm-svn: 12980
2004-04-16 06:03:17 +00:00
Chris Lattner
644ad23b21
Make sure to check for a very bad class of errors: an instruction
...
that does not dominate all of its users, but is in the same basic block as
its users. This class of error is what caused the mysterious CBE only
failures last night.
llvm-svn: 12979
2004-04-16 05:51:47 +00:00
Chris Lattner
8f8bd7daac
Bugpoint was not correctly capturing stderr! This caused it to "find" bugs
...
that didn't exist, missing the ones that do :(
llvm-svn: 12978
2004-04-16 05:35:58 +00:00
Chris Lattner
06eda01d1b
Fix Inline/2004-04-15-InlineDeletesCall.ll
...
Basically we were using SimplifyCFG as a huge sledgehammer for a simple
optimization. Because simplifycfg does so many things, we can't use it
for this purpose.
llvm-svn: 12977
2004-04-16 05:17:59 +00:00
Misha Brukman
df6d740b3e
Add note about easier way to debug tests in the llvm tree.
...
llvm-svn: 12972
2004-04-15 21:01:21 +00:00
Misha Brukman
aa2862894c
Add note about passing arguments to program being debugged.
...
llvm-svn: 12970
2004-04-15 20:49:32 +00:00
Chris Lattner
acf8b5189f
New testcase that Brian provided which crashes the inliner
...
llvm-svn: 12969
2004-04-15 20:45:45 +00:00
Chris Lattner
ac2b465cb4
Fix a bug in the previous checkin: if the exit block is not the same as
...
the back-edge block, we must check the preincremented value.
llvm-svn: 12968
2004-04-15 20:26:22 +00:00
Brian Gaeke
e708b1d5ef
Give SparcV9CodeEmitter a head-of-file comment and a PassName.
...
llvm-svn: 12967
2004-04-15 20:23:13 +00:00
Misha Brukman
97e81286e5
If we're going to use tabs, use them consistently. Maybe doxygen will find the
...
@parameter line documentation that way, too.
llvm-svn: 12966
2004-04-15 15:38:48 +00:00
Misha Brukman
978fd39ec7
Removed obsolete doxygen options (they were blank anyway).
...
llvm-svn: 12965
2004-04-15 15:33:49 +00:00
Misha Brukman
be6fcab94d
The "best" of both worlds: readable C++ comments and valid HTML For doxygen.
...
llvm-svn: 12964
2004-04-15 15:30:15 +00:00
Misha Brukman
3fa1037635
Don't use invalid HTML in doxygen comments.
...
llvm-svn: 12963
2004-04-15 15:24:55 +00:00
Misha Brukman
ab36a84bda
Don't use invalid HTML in a doxygen comment.
...
llvm-svn: 12962
2004-04-15 15:23:45 +00:00
Chris Lattner
dcf2ca93e6
Change the canonical induction variable that we insert.
...
Instead of producing code like this:
Loop:
X = phi 0, X2
...
X2 = X + 1
if (X != N-1) goto Loop
We now generate code that looks like this:
Loop:
X = phi 0, X2
...
X2 = X + 1
if (X2 != N) goto Loop
This has two big advantages:
1. The trip count of the loop is now explicit in the code, allowing
the direct implementation of Loop::getTripCount()
2. This reduces register pressure in the loop, and allows X and X2 to be
put into the same register.
As a consequence of the second point, the code we generate for loops went
from:
.LBB2: # no_exit.1
...
mov %EDI, %ESI
inc %EDI
cmp %ESI, 2
mov %ESI, %EDI
jne .LBB2 # PC rel: no_exit.1
To:
.LBB2: # no_exit.1
...
inc %ESI
cmp %ESI, 3
jne .LBB2 # PC rel: no_exit.1
... which has two fewer moves, and uses one less register.
llvm-svn: 12961
2004-04-15 15:21:43 +00:00
Chris Lattner
a86cf626b5
add some helpful methods. Rearrange #includes to proper order
...
llvm-svn: 12960
2004-04-15 15:16:02 +00:00
Chris Lattner
5c992ad183
Add some helpful methods
...
llvm-svn: 12959
2004-04-15 15:15:40 +00:00
Chris Lattner
e0156bd979
Factor a bunch of classes out into a public header
...
llvm-svn: 12958
2004-04-15 15:07:24 +00:00
Chris Lattner
0d220df227
Publically export all of these classes from the ScalarEvolutions.cpp file
...
llvm-svn: 12957
2004-04-15 15:06:59 +00:00
Chris Lattner
ff600e280d
Unbreak the build
...
llvm-svn: 12956
2004-04-15 14:17:43 +00:00
Chris Lattner
276a6e102c
Implement a FIXME: if we're going to insert a cast, we might as well only
...
insert it once!
llvm-svn: 12955
2004-04-14 22:01:22 +00:00
John Criswell
8a4525ae64
Remove code to adjust the iterator for llvm.readio and llvm.writeio.
...
The iterator is pointing at the next instruction which should not disappear
when doing the load/store replacement.
llvm-svn: 12954
2004-04-14 21:27:56 +00:00
Brian Gaeke
8e2fb33172
Fix typo.
...
llvm-svn: 12953
2004-04-14 21:21:56 +00:00
Chris Lattner
7f5e4b6d55
This is a trivial tweak to the addrec insertion code: insert the increment
...
at the bottom of the loop instead of the top. This reduces the number of
overlapping live ranges a lot, for example, eliminating a spill in an important
loop in 183.equake with linear scan.
I still need to make the exit comparison of the loop use the post-incremented
version of this variable, but this is an easy first step.
llvm-svn: 12952
2004-04-14 21:11:25 +00:00