aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2004-04-18After unrolling our single basic block loop, fold it into the preheader and exitChris Lattner
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-18Fix a bug: this does not preserve the CFG!Chris Lattner
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-18Add a new method, add a check missing that caused a segfault if a loop didn'tChris Lattner
have a canonical indvar git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13032 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18Initial checkin of a simple loop unroller. This pass is extremely basic andChris Lattner
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-18Make the tail duplication threshold accessible from the command line instead ↵Chris Lattner
of hardcoded git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13025 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17Fix a memory leak. We leaked the vector holding the entries in switch tables.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13023 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17Add the ability to compute exit values for complex loop using unanalyzableChris Lattner
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-17If the loop executes a constant number of times, try a bit harder to replaceChris Lattner
exit values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13018 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-17Add the ability to compute trip counts that are only controlled by constantsChris Lattner
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-17Fix a HUGE pessimization on X86. The indvars pass was taking thisChris Lattner
(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-17Even if there are not any induction variables in the loop, if we can computeChris Lattner
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-16Add support for evaluation of exp/log/log10/powChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13011 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Fix some really nasty dominance bugs that were exposed by my patch toChris Lattner
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-16Fix retriving parent Function.Misha Brukman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13001 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Include <cmath> for compatibility with gcc 3.0.x (the system compiler onBrian Gaeke
Debian.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12986 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Assert if deleting BasicBlock before removing it from Function.Misha Brukman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12983 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Fix some of the strange CBE-only failures that happened last night.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12980 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Make sure to check for a very bad class of errors: an instructionChris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12979 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Bugpoint was not correctly capturing stderr! This caused it to "find" bugsChris Lattner
that didn't exist, missing the ones that do :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12978 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16Fix Inline/2004-04-15-InlineDeletesCall.llChris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12977 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Fix a bug in the previous checkin: if the exit block is not the same asChris Lattner
the back-edge block, we must check the preincremented value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12968 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Give SparcV9CodeEmitter a head-of-file comment and a PassName.Brian Gaeke
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12967 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Don't use invalid HTML in a doxygen comment.Misha Brukman
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12962 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Change the canonical induction variable that we insert.Chris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12961 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15add some helpful methods. Rearrange #includes to proper orderChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12960 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Factor a bunch of classes out into a public headerChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12958 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15Unbreak the buildChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12956 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Implement a FIXME: if we're going to insert a cast, we might as well onlyChris Lattner
insert it once! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12955 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Remove code to adjust the iterator for llvm.readio and llvm.writeio.John Criswell
The iterator is pointing at the next instruction which should not disappear when doing the load/store replacement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12954 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Fix typo.Brian Gaeke
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12953 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14This is a trivial tweak to the addrec insertion code: insert the incrementChris Lattner
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12952 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Add a TargetData to the PassManager regardless of the TargetMachine.Brian Gaeke
This should unbreak the Sparc JIT again. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12949 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Remove the return type check for llvm.readio. This check is done for allJohn Criswell
functions and is not needed here. Simplify the pointer type check per Chris's suggestions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12945 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Added code to verify that llvm.readio's pointer argument returns somethingJohn Criswell
that matches its return type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12944 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14Finish adding the llvm.readio and llvm.writeio intrinsics.John Criswell
Sorry these didn't get in yesterday. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12942 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14ADd a trivial instcombine: load null -> nullChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12940 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14This is the real fix for Codegen/X86/2004-04-13-FPCMOV-Crash.llx which worksChris Lattner
even when the "optimization" I added before is turned off. It generates this extremely pointless code: test: fld QWORD PTR [%ESP + 4] mov %AL, 0 test %AL, %AL fcmove %ST(0), %ST(0) ret Good thing the optimizer will have removed this before code generation anyway. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12939 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Added support for the llvm.readio and llvm.writeio intrinsics.John Criswell
On x86, memory operations occur in-order, so these are just lowered into volatile loads and stores. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12936 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Implement a small optimization, which papers over the problem inChris Lattner
X86/2004-04-13-FPCMOV-Crash.llx A more robust fix is to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12935 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Add SCCP support for constant folding calls, implementing:Chris Lattner
test/Regression/Transforms/SCCP/calltest.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12921 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Add a simple call constant propagation interface.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12919 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Constant propagation should remove the dead instructionsChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12917 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13I don't think we have to have 4 extra allocated (but unused) bytes on the stack.Brian Gaeke
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12905 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13I started working on casts, but I don't have anything compilable yet.Brian Gaeke
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12903 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Emit the immediate form of in/out when possible.Chris Lattner
Fix several bugs in the intrinsics: 1. Make sure to copy the input registers before the instructions that use them 2. Make sure to copy the value returned by 'in' out of EAX into the register it is supposed to be in. This fixes assertions when using in/out and linear scan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12896 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Add immediate forms of in/out. Use let to shorten linesChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12895 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Add support for new instruction typeChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12894 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Add support for the printImplicitDefsBefore flagChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12893 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Fix LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.llChris Lattner
LoopSimplify was not updating dominator frontiers correctly in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12890 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13Refactor code a bit to make it simpler and eliminate the gotoChris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12888 91177308-0d34-0410-b5e6-96231b3b80d8