Chris Lattner
74332be31e
New testcase
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13067 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:06:34 +00:00
Chris Lattner
8277567dc6
Add accessor for a Loop Unswitching pass
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13066 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 06:28:37 +00:00
Chris Lattner
06ac2bef15
Eliminate a poorly conceived method
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13065 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 06:26:46 +00:00
Chris Lattner
45a1cf87d4
It's not just a printer, it's actually an analysis too
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13064 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:42:32 +00:00
Misha Brukman
de4803d0af
As per Chris, greatly simplify handling of external functions by using the
...
wrapper idea uniformly: we can use Value::replaceAllUsesWith() instead of
special-casing by class of user.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13063 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:36:47 +00:00
Misha Brukman
f6f7ec1ee2
* Remove note about "UNSUPPORTED: " feature that just became supported
...
* Fix usage of <p> tag and some grammar
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13062 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:28:39 +00:00
Misha Brukman
b687d82b02
* Reorder #includes
...
* Wrap a long line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13061 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:12:35 +00:00
Misha Brukman
e8cad78698
Display sample bugpoint output with the `code' stylesheet class.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13060 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:07:29 +00:00
Chris Lattner
072b163424
* Improve file header comment
...
* Remove #include
* Add some methods to update loop/loopinfo
* Stop explicitly holding the loop depth in the Loop class. Instead, just
dynamically calculate it. This makes it easier to update LoopInfo as a
result of transformations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13059 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:03:19 +00:00
Chris Lattner
446b86d381
Remove code to update loop depths
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13058 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:02:09 +00:00
Chris Lattner
5864aebe92
Add #include
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13057 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:01:23 +00:00
Misha Brukman
cb00336384
Add notes about PRs 38 and 290 being fixed.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13056 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 03:01:01 +00:00
Misha Brukman
a7aadf1642
Wrap (some) lines to 80 cols.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13055 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 02:56:49 +00:00
Misha Brukman
dc7fef83dc
Finally implement rewriting global initializers which use external functions
...
by creating an internal wrapper function with same signature as the external
function, and use it instead of the "real" function.
The wrapper then calls the external function using the same JIT function
resolution API that has been used before for rewriting instructions, since the
wrapper has an explicit call instruction which we can rewrite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13054 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 01:12:01 +00:00
Chris Lattner
4e77cc46ac
Provide an interface that is more convenient for iterating over the blocks
...
in a loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13052 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 23:37:03 +00:00
Chris Lattner
3280f7bd55
Move isLoopInvariant to the Loop class
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13051 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:46:08 +00:00
Chris Lattner
85661d0978
Add new method
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13050 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:45:27 +00:00
Chris Lattner
88d3ef2c74
Add new method.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13049 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:45:16 +00:00
Chris Lattner
59fb87d469
Correct rewriting of exit blocks after my last patch
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13048 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:27:10 +00:00
Chris Lattner
343c0cfa19
Fix computation of exit blocks
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13047 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:21:41 +00:00
Chris Lattner
5fa802fe27
Loop exit sets are no longer explicitly held, they are dynamically computed on demand.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13046 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:15:13 +00:00
Chris Lattner
f1ab4b4eac
Change the ExitBlocks list from being explicitly contained in the Loop
...
structure to being dynamically computed on demand. This makes updating
loop information MUCH easier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13045 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:14:10 +00:00
Chris Lattner
7c8781e71f
Spiff is no longer in our tree
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13041 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 18:26:38 +00:00
Chris Lattner
e3a55865bb
Reduce the unrolling limit
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13040 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 18:06:14 +00:00
Chris Lattner
cc43909bb6
If the preheader of the loop was the entry block of the function, make sure
...
that the exit block of the loop becomes the new entry block of the function.
This was causing a verifier assertion on 252.eon.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13039 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 17:38:42 +00:00
Chris Lattner
998f44f859
Be much more careful about how we update instructions outside of the loop
...
using instructions inside of the loop. This should fix the MishaTest failure
from last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13038 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 17:32:39 +00:00
Chris Lattner
df75125ff5
Another testcase
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13037 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:55:57 +00:00
Chris Lattner
3048bd1d3e
Implement method
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13036 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:54:48 +00:00
Chris Lattner
9afb24bf08
Add a new method
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13035 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:54:34 +00:00
Chris Lattner
50ca0a195a
After unrolling our single basic block loop, fold it into the preheader and exit
...
block. The primary motivation for doing this is that we can now unroll nested loops.
This makes a pretty big difference in some cases. For example, in 183.equake,
we are now beating the native compiler with the CBE, and we are a lot closer
with LLC.
I'm now going to play around a bit with the unroll factor and see what effect
it really has.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13034 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 06:27:43 +00:00
Chris Lattner
9c2cc4626b
Fix a bug: this does not preserve the CFG!
...
While we're at it, add support for updating loop information correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13033 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:38:37 +00:00
Chris Lattner
24199db80e
Add a new method, add a check missing that caused a segfault if a loop didn't
...
have a canonical indvar
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13032 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:38:05 +00:00
Chris Lattner
4e55b7d2c6
Allow clients to delete loops, add a new method
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13031 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:37:42 +00:00
Chris Lattner
93d82020ef
Move loop optimization passes up, add loop unroller
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13030 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:21:01 +00:00
Chris Lattner
4c174a7bba
Add prototype
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13029 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:20:32 +00:00
Chris Lattner
83bf2880c3
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13028 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 05:20:17 +00:00
Chris Lattner
3c85eef81a
Make the tail duplication threshold accessible from the command line instead of hardcoded
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13025 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 00:52:43 +00:00
Chris Lattner
f57a43da9c
Fix a memory leak. We leaked the vector holding the entries in switch tables.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13023 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 23:49:15 +00:00
Chris Lattner
f49090035f
New testcase
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13020 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 23:00:51 +00:00
Chris Lattner
3221ad0db7
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13019 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 22:58:41 +00:00
Chris Lattner
20aa098ba6
If the loop executes a constant number of times, try a bit harder to replace
...
exit values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13018 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:44:09 +00:00
Chris Lattner
7980fb9007
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13017 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:36:24 +00:00
Chris Lattner
4f1134e51a
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
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13016 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:16:10 +00:00
Chris Lattner
f50af088f1
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13015 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17 18:08:33 +00:00
Chris Lattner
f5b9eb37a9
Add support for evaluation of exp/log/log10/pow
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13011 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 22:35:33 +00:00
Chris Lattner
657253119e
Fix some really nasty dominance bugs that were exposed by my patch to
...
make the verifier more strict. This fixes building zlib
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13002 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 18:08:07 +00:00
Misha Brukman
ea51deb18a
Fix retriving parent Function.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13001 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 17:37:12 +00:00
Misha Brukman
ef2b0db858
Fit comment into 80 cols.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12996 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 17:13:52 +00:00
Brian Gaeke
e773b869de
Regenerated using autoconf-2.57.
...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12995 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 17:13:44 +00:00
Brian Gaeke
dbaf981345
Refactor external benchmark checking stuff into one hairy
...
macro-to-bind-them-all, called EXTERNAL_BENCHMARK().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12994 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 17:13:33 +00:00