- Apr 17, 2004
-
-
Chris Lattner authored
exit values. llvm-svn: 13018
-
Chris Lattner authored
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
-
Chris Lattner authored
(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
-
Chris Lattner authored
the trip count for the loop, insert one so that we can canonicalize the exit condition. llvm-svn: 13015
-
Chris Lattner authored
llvm-svn: 13011
-
- Apr 16, 2004
-
-
Chris Lattner authored
make the verifier more strict. This fixes building zlib llvm-svn: 13002
-
Misha Brukman authored
llvm-svn: 13001
-
Misha Brukman authored
llvm-svn: 12996
-
Brian Gaeke authored
llvm-svn: 12995
-
Brian Gaeke authored
macro-to-bind-them-all, called EXTERNAL_BENCHMARK(). llvm-svn: 12994
-
Misha Brukman authored
llvm-svn: 12993
-
Brian Gaeke authored
llvm-svn: 12990
-
Misha Brukman authored
* Wrap long lines to 80 cols llvm-svn: 12988
-
Brian Gaeke authored
Debian.) llvm-svn: 12986
-
Brian Gaeke authored
Debian.) llvm-svn: 12985
-
Brian Gaeke authored
should not build projects. llvm-svn: 12984
-
Misha Brukman authored
llvm-svn: 12983
-
Misha Brukman authored
llvm-svn: 12982
-
Chris Lattner authored
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
-
Chris Lattner authored
llvm-svn: 12980
-
Chris Lattner authored
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
-
Chris Lattner authored
that didn't exist, missing the ones that do :( llvm-svn: 12978
-
Chris Lattner authored
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
-
- Apr 15, 2004
-
-
Misha Brukman authored
llvm-svn: 12972
-
Misha Brukman authored
llvm-svn: 12970
-
Chris Lattner authored
llvm-svn: 12969
-
Chris Lattner authored
the back-edge block, we must check the preincremented value. llvm-svn: 12968
-
Brian Gaeke authored
llvm-svn: 12967
-
Misha Brukman authored
@parameter line documentation that way, too. llvm-svn: 12966
-
Misha Brukman authored
llvm-svn: 12965
-
Misha Brukman authored
llvm-svn: 12964
-
Misha Brukman authored
llvm-svn: 12963
-
Misha Brukman authored
llvm-svn: 12962
-
Chris Lattner authored
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
-
Chris Lattner authored
llvm-svn: 12960
-
Chris Lattner authored
llvm-svn: 12959
-
Chris Lattner authored
llvm-svn: 12958
-
Chris Lattner authored
llvm-svn: 12957
-
Chris Lattner authored
llvm-svn: 12956
-
Chris Lattner authored
insert it once! llvm-svn: 12955
-