Commit Graph

11781 Commits

Author SHA1 Message Date
Chris Lattner 663ebc3ec6 It's not just a printer, it's actually an analysis too
llvm-svn: 13064
2004-04-19 03:42:32 +00:00
Misha Brukman ce89b392c6 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.

llvm-svn: 13063
2004-04-19 03:36:47 +00:00
Misha Brukman d2493e1565 * Remove note about "UNSUPPORTED: " feature that just became supported
* Fix usage of <p> tag and some grammar

llvm-svn: 13062
2004-04-19 03:28:39 +00:00
Misha Brukman 8a32c6d91b * Reorder #includes
* Wrap a long line

llvm-svn: 13061
2004-04-19 03:12:35 +00:00
Misha Brukman 4825e215c0 Display sample bugpoint output with the `code' stylesheet class.
llvm-svn: 13060
2004-04-19 03:07:29 +00:00
Chris Lattner 5414021060 * 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.

llvm-svn: 13059
2004-04-19 03:03:19 +00:00
Chris Lattner 32447c55fe Remove code to update loop depths
llvm-svn: 13058
2004-04-19 03:02:09 +00:00
Chris Lattner bc02177fdc Add #include
llvm-svn: 13057
2004-04-19 03:01:23 +00:00
Misha Brukman e70502328e Add notes about PRs 38 and 290 being fixed.
llvm-svn: 13056
2004-04-19 03:01:01 +00:00
Misha Brukman 017f2f3405 Wrap (some) lines to 80 cols.
llvm-svn: 13055
2004-04-19 02:56:49 +00:00
Misha Brukman 8301864215 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.

llvm-svn: 13054
2004-04-19 01:12:01 +00:00
Chris Lattner 732b5d5bba Provide an interface that is more convenient for iterating over the blocks
in a loop.

llvm-svn: 13052
2004-04-18 23:37:03 +00:00
Chris Lattner fc44a25bcb Move isLoopInvariant to the Loop class
llvm-svn: 13051
2004-04-18 22:46:08 +00:00
Chris Lattner 26ba2f5fe8 Add new method
llvm-svn: 13050
2004-04-18 22:45:27 +00:00
Chris Lattner d4d66c86c0 Add new method.
llvm-svn: 13049
2004-04-18 22:45:16 +00:00
Chris Lattner 827826320d Correct rewriting of exit blocks after my last patch
llvm-svn: 13048
2004-04-18 22:27:10 +00:00
Chris Lattner d6ce359d3b Fix computation of exit blocks
llvm-svn: 13047
2004-04-18 22:21:41 +00:00
Chris Lattner 35eaa55cfc Loop exit sets are no longer explicitly held, they are dynamically computed on demand.
llvm-svn: 13046
2004-04-18 22:15:13 +00:00
Chris Lattner d72c3eb54e 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.

llvm-svn: 13045
2004-04-18 22:14:10 +00:00
Chris Lattner bf3c8763c0 Spiff is no longer in our tree
llvm-svn: 13041
2004-04-18 18:26:38 +00:00
Chris Lattner d15250240c Reduce the unrolling limit
llvm-svn: 13040
2004-04-18 18:06:14 +00:00
Chris Lattner 30ae18155d 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.

llvm-svn: 13039
2004-04-18 17:38:42 +00:00
Chris Lattner 230bcb6b35 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.

llvm-svn: 13038
2004-04-18 17:32:39 +00:00
Chris Lattner 3796974563 Another testcase
llvm-svn: 13037
2004-04-18 06:55:57 +00:00
Chris Lattner e375a4fdc2 Implement method
llvm-svn: 13036
2004-04-18 06:54:48 +00:00
Chris Lattner 5f46b7044c Add a new method
llvm-svn: 13035
2004-04-18 06:54:34 +00:00
Chris Lattner 4d52e1e401 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.

llvm-svn: 13034
2004-04-18 06:27:43 +00:00
Chris Lattner f2cc841619 Fix a bug: this does not preserve the CFG!
While we're at it, add support for updating loop information correctly.

llvm-svn: 13033
2004-04-18 05:38:37 +00:00
Chris Lattner 1472c63fb9 Add a new method, add a check missing that caused a segfault if a loop didn't
have a canonical indvar

llvm-svn: 13032
2004-04-18 05:38:05 +00:00
Chris Lattner c9de38d316 Allow clients to delete loops, add a new method
llvm-svn: 13031
2004-04-18 05:37:42 +00:00
Chris Lattner bf9ba24155 Move loop optimization passes up, add loop unroller
llvm-svn: 13030
2004-04-18 05:21:01 +00:00
Chris Lattner e4ce5dbd1d Add prototype
llvm-svn: 13029
2004-04-18 05:20:32 +00:00
Chris Lattner 946b255977 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 c14da9600b 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 ca96cee67b 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 bc4118f316 New testcase
llvm-svn: 13020
2004-04-17 23:00:51 +00:00
Chris Lattner dd73047673 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 a814080025 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 4021d1af5a 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 1e9ac1a45e 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 885a6eb74d 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 a43312d30b Add support for evaluation of exp/log/log10/pow
llvm-svn: 13011
2004-04-16 22:35:33 +00:00
Chris Lattner 284d3b0311 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 ede10c9185 Fix retriving parent Function.
llvm-svn: 13001
2004-04-16 17:37:12 +00:00
Misha Brukman 66532f5e8a Fit comment into 80 cols.
llvm-svn: 12996
2004-04-16 17:13:52 +00:00
Brian Gaeke efe9105979 Regenerated using autoconf-2.57.
llvm-svn: 12995
2004-04-16 17:13:44 +00:00
Brian Gaeke fe766057a9 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 c08a573515 Add idea about a disassembler.
llvm-svn: 12993
2004-04-16 16:55:30 +00:00
Brian Gaeke ec240edcc8 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 0c88a74044 * Fix capitalization of PICk
* Wrap long lines to 80 cols

llvm-svn: 12988
2004-04-16 16:20:07 +00:00
Brian Gaeke 174633b078 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 8bd536a311 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 7850dd6877 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 0af4a9c12b Assert if deleting BasicBlock before removing it from Function.
llvm-svn: 12983
2004-04-16 15:47:21 +00:00
Misha Brukman 1a6b00cd57 Assert if Instruction is being deleted before being removed from BasicBlock.
llvm-svn: 12982
2004-04-16 15:46:43 +00:00
Chris Lattner 994e48ff09 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 9e9b2b7474 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 0377e4384f 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 82876bdb2a 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 0328d75c83 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 272322e591 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 c21921cec7 Add note about passing arguments to program being debugged.
llvm-svn: 12970
2004-04-15 20:49:32 +00:00
Chris Lattner fbc88b6cbd New testcase that Brian provided which crashes the inliner
llvm-svn: 12969
2004-04-15 20:45:45 +00:00
Chris Lattner d7a559e353 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 5bee0f3068 Give SparcV9CodeEmitter a head-of-file comment and a PassName.
llvm-svn: 12967
2004-04-15 20:23:13 +00:00
Misha Brukman cf2b18791a 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 a34f067bac Removed obsolete doxygen options (they were blank anyway).
llvm-svn: 12965
2004-04-15 15:33:49 +00:00
Misha Brukman b4f20ea496 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 cd19073a70 Don't use invalid HTML in doxygen comments.
llvm-svn: 12963
2004-04-15 15:24:55 +00:00
Misha Brukman d061d81571 Don't use invalid HTML in a doxygen comment.
llvm-svn: 12962
2004-04-15 15:23:45 +00:00
Chris Lattner 0cec5cb92c 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 d9dc425376 add some helpful methods. Rearrange #includes to proper order
llvm-svn: 12960
2004-04-15 15:16:02 +00:00
Chris Lattner 6580bbda3d Add some helpful methods
llvm-svn: 12959
2004-04-15 15:15:40 +00:00
Chris Lattner b4f681b42b Factor a bunch of classes out into a public header
llvm-svn: 12958
2004-04-15 15:07:24 +00:00
Chris Lattner 3598d13b1c Publically export all of these classes from the ScalarEvolutions.cpp file
llvm-svn: 12957
2004-04-15 15:06:59 +00:00
Chris Lattner a4e4a63856 Unbreak the build
llvm-svn: 12956
2004-04-15 14:17:43 +00:00
Chris Lattner d420fe63ea 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 e3e2c91997 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 0174347d9a Fix typo.
llvm-svn: 12953
2004-04-14 21:21:56 +00:00
Chris Lattner 8a9fd94cfe 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
Brian Gaeke aec2bcd63b Add a TargetData to the PassManager regardless of the TargetMachine.
This should unbreak the Sparc JIT again.

llvm-svn: 12949
2004-04-14 17:45:52 +00:00
Brian Gaeke 9a2e37bccd Add a copy constructor for TargetData.
llvm-svn: 12948
2004-04-14 17:45:48 +00:00
Chris Lattner cea7f660bc We are now on LLVM 1.3
Make autoconf default to checking to look to see if our funny directory exists

llvm-svn: 12947
2004-04-14 16:32:34 +00:00
Chris Lattner 6d06918ef0 Regenerated
llvm-svn: 12946
2004-04-14 16:32:09 +00:00
John Criswell c4e72c9a0a Remove the return type check for llvm.readio. This check is done for all
functions and is not needed here.
Simplify the pointer type check per Chris's suggestions.

llvm-svn: 12945
2004-04-14 15:06:48 +00:00
John Criswell 0c654c6a4e Added code to verify that llvm.readio's pointer argument returns something
that matches its return type.

llvm-svn: 12944
2004-04-14 14:49:36 +00:00
John Criswell 917b641609 Test for memory mapped I/O intrinsics.
llvm-svn: 12943
2004-04-14 13:52:56 +00:00
John Criswell 23c48d63d6 Finish adding the llvm.readio and llvm.writeio intrinsics.
Sorry these didn't get in yesterday.

llvm-svn: 12942
2004-04-14 13:46:52 +00:00
Chris Lattner 6679e46b59 ADd a trivial instcombine: load null -> null
llvm-svn: 12940
2004-04-14 03:28:36 +00:00
Chris Lattner 0dc099c2b5 This is the real fix for Codegen/X86/2004-04-13-FPCMOV-Crash.llx which works
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.  :)

llvm-svn: 12939
2004-04-14 02:42:32 +00:00
Chris Lattner 52acdaacc7 Temporarily hack in the intrinsics that John added. I expect him to finish up their addition, but in the meantime, the build should not be broken.
llvm-svn: 12938
2004-04-14 02:22:54 +00:00
John Criswell beded72a08 Added support for the llvm.readio and llvm.writeio intrinsics.
On x86, memory operations occur in-order, so these are just lowered into
volatile loads and stores.

llvm-svn: 12936
2004-04-13 22:13:14 +00:00
Chris Lattner 9042e381d8 Implement a small optimization, which papers over the problem in
X86/2004-04-13-FPCMOV-Crash.llx

A more robust fix is to follow.

llvm-svn: 12935
2004-04-13 21:56:09 +00:00
Chris Lattner ed94fef7e3 Fix bug, add support for +/-
llvm-svn: 12934
2004-04-13 21:48:43 +00:00
Chris Lattner 8662beeecd new testcase that crashes the fp stackifier
llvm-svn: 12932
2004-04-13 21:44:54 +00:00
Chris Lattner ed7a7d20c9 We actually don't have spiff anymore
llvm-svn: 12929
2004-04-13 20:59:47 +00:00
Chris Lattner 9a3ac1a956 Out with spiff, in with fpcmp
llvm-svn: 12928
2004-04-13 20:59:24 +00:00
Chris Lattner e542c1c422 Remove spiff. Though it looked good, it was not really as spiffy as it seemed
llvm-svn: 12927
2004-04-13 20:58:42 +00:00
Chris Lattner 5613bcc258 Okay, spiff is completely incapable of handling files of nontrivial size.
Here is a simple minimal program that does what we want.  Instead of taking
minutes to compare mesa's output, and crashing on binary files (like spiff
does), this take < .02s in the common case and doesn't crash.

llvm-svn: 12926
2004-04-13 20:55:49 +00:00
Chris Lattner cb5e795f1f Add a note
llvm-svn: 12922
2004-04-13 19:48:55 +00:00
Chris Lattner ff9362a8da Add SCCP support for constant folding calls, implementing:
test/Regression/Transforms/SCCP/calltest.ll

llvm-svn: 12921
2004-04-13 19:43:54 +00:00
Chris Lattner 9d42084081 New testcase
llvm-svn: 12920
2004-04-13 19:43:33 +00:00
Chris Lattner ca52d0468e Add a simple call constant propagation interface.
llvm-svn: 12919
2004-04-13 19:28:52 +00:00
Chris Lattner 7dacdb6f13 Add new interfaces
llvm-svn: 12918
2004-04-13 19:28:32 +00:00
Chris Lattner d0dc6d5295 Constant propagation should remove the dead instructions
llvm-svn: 12917
2004-04-13 19:28:20 +00:00
Chris Lattner e3debac3cd New testcase
llvm-svn: 12916
2004-04-13 19:28:09 +00:00
Brian Gaeke 9a79ed7b89 Regenerated using autoconf-2.57.
llvm-svn: 12915
2004-04-13 19:03:49 +00:00
Brian Gaeke fca4720590 Rewrite POV-Ray check as per PR301
llvm-svn: 12914
2004-04-13 19:02:51 +00:00
Chris Lattner becf6365d6 Increase buffer size again. *sigh*
llvm-svn: 12912
2004-04-13 18:43:18 +00:00
Chris Lattner f37bd007e4 Don't index spiff. It should not count as lines of LLVM code
llvm-svn: 12911
2004-04-13 18:37:51 +00:00
Chris Lattner 763596e28d Fixed sized limits are bad... duh.
llvm-svn: 12908
2004-04-13 18:34:16 +00:00
Chris Lattner 7b9733dac2 Really spiff, don't chatter :)
llvm-svn: 12907
2004-04-13 18:33:21 +00:00
Brian Gaeke 6f6e4b9f59 I don't think we have to have 4 extra allocated (but unused) bytes on the stack.
llvm-svn: 12905
2004-04-13 18:28:37 +00:00
Brian Gaeke 969795b4ea I started working on casts, but I don't have anything compilable yet.
llvm-svn: 12903
2004-04-13 18:27:46 +00:00
Brian Gaeke bacab88d42 Don't underline diffs
llvm-svn: 12902
2004-04-13 18:24:01 +00:00
Chris Lattner c71b096672 Emit the immediate form of in/out when possible.
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.

llvm-svn: 12896
2004-04-13 17:20:37 +00:00
Chris Lattner a340febe52 Add immediate forms of in/out. Use let to shorten lines
llvm-svn: 12895
2004-04-13 17:19:31 +00:00
Chris Lattner eaa28a29ae Add support for new instruction type
llvm-svn: 12894
2004-04-13 17:18:51 +00:00
Chris Lattner 27b2e2cdc0 Add support for the printImplicitDefsBefore flag
llvm-svn: 12893
2004-04-13 17:18:39 +00:00
Chris Lattner e342a8ef49 Make the testcase more challenging
llvm-svn: 12892
2004-04-13 17:18:07 +00:00
Chris Lattner 34fba8eb00 Reenable library now that the loopsimplify bug is fixed
llvm-svn: 12891
2004-04-13 16:24:53 +00:00
Chris Lattner 89e959bb1f Fix LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll
LoopSimplify was not updating dominator frontiers correctly in some cases.

llvm-svn: 12890
2004-04-13 16:23:25 +00:00
Chris Lattner a7aeb506dd New testcase where loop simplify is not updating domfrontiers correctly
llvm-svn: 12889
2004-04-13 16:22:04 +00:00
Chris Lattner a6e22814ab Refactor code a bit to make it simpler and eliminate the goto
llvm-svn: 12888
2004-04-13 15:21:18 +00:00
Chris Lattner 54dcea809f Add notes about some of the code quality improvements that have gone in
llvm-svn: 12887
2004-04-13 14:43:35 +00:00
Chris Lattner 277f7e6ebc Temporary hack to get the nightly tester running
llvm-svn: 12886
2004-04-13 13:57:29 +00:00
John Criswell ed868e14ff Added Spiff.
llvm-svn: 12885
2004-04-13 13:42:38 +00:00
Chris Lattner 8417052938 This patch addresses PR35: Loop simplify should reconstruct nested loops.
This is fairly straight-forward, but was a real nightmare to get just
perfect.  aarg.  :)

llvm-svn: 12884
2004-04-13 05:05:33 +00:00
Brian Gaeke ff27406cf9 Clean up the Spiff code so that it emits fewer warnings. This
consists mostly of changing sloppy K&R C code to slightly more
disciplined K&R C code, and doing the usual things to shut gcc up.

llvm-svn: 12877
2004-04-13 03:24:45 +00:00
Brian Gaeke 2ec7dfc278 Build Spiff directory
llvm-svn: 12876
2004-04-12 22:53:51 +00:00
Brian Gaeke 4ae2642fd4 Add the Spiff fp-aware diff utility from Bellcore
llvm-svn: 12875
2004-04-12 22:53:24 +00:00
Brian Gaeke bb0f2db881 We don't need to insert TargetData into the PassManager here.
llvm-svn: 12874
2004-04-12 21:46:31 +00:00
Chris Lattner 176b4c2439 new testcase
llvm-svn: 12873
2004-04-12 20:59:07 +00:00
Alkis Evlogimenos 8f2df3aa3c Fix bug introduced in previous commit.
llvm-svn: 12872
2004-04-12 20:26:39 +00:00
Chris Lattner 55b7ef5a81 Add some methods that are useful for updating loop information.
llvm-svn: 12871
2004-04-12 20:26:17 +00:00
Alkis Evlogimenos 7ab640fdcb Update testcase to illustrate the coalescing problem. The previous one did not work because of a fix in the x86 instruction selector.
llvm-svn: 12870
2004-04-12 19:04:22 +00:00
Alkis Evlogimenos 0ede7ec4f8 Correctly compute spill weights
llvm-svn: 12869
2004-04-12 17:39:20 +00:00
John Criswell b7147b33a0 Added testcase for the llvm.readport and llvm.writeport intrinsics.
llvm-svn: 12868
2004-04-12 16:42:43 +00:00
John Criswell 7a57647f97 Corrected the descriptions of the llvm.writeport and llvm.writeio
intrinsics.

Modified llvm.readio and llvm.writeio to use pointers to memory instead
of integers.  This should take care of problems such as different pointer
sizes, casting integers to pointers, weird architectural pointer types, etc.

Re-worded the description of llvm.readio and llvm.writeio so that it should
be more clear as to why they should be used over regular loads/stores for
I/O.

llvm-svn: 12867
2004-04-12 16:33:19 +00:00
Alkis Evlogimenos b753c8c9c5 Print def lists a bit more compactly
llvm-svn: 12866
2004-04-12 15:57:58 +00:00
Alkis Evlogimenos 70bbce62b1 Add same value coalescing testcase
llvm-svn: 12865
2004-04-12 15:40:25 +00:00
John Criswell a450122ebf Added initial design for the llvm.readio and llvm.writeio intrinsics.
llvm-svn: 12864
2004-04-12 15:02:16 +00:00
Chris Lattner a2b279e89c Add a couple more IPO's
llvm-svn: 12863
2004-04-12 05:38:15 +00:00
Chris Lattner 0a7526470b finegrainify namespacification
llvm-svn: 12862
2004-04-12 05:38:01 +00:00
Chris Lattner be43544429 Actually update the call graph as the inliner changes it. This allows us to
execute other CallGraphSCCPasses after the inliner without crashing.

llvm-svn: 12861
2004-04-12 05:37:29 +00:00
Chris Lattner 8b6db18ac3 Change the call graph class to have TWO external nodes, making call graph
SCC passes much more useful.  In particular, this should fix the incredibly
stupid missed inlining opportunities that the inliner suffered from.

llvm-svn: 12860
2004-04-12 05:36:32 +00:00
Chris Lattner c9e37d7cc9 Hrm, operator new and new[] do not belong here. We should not CSE them! :)
llvm-svn: 12859
2004-04-12 05:16:42 +00:00
Chris Lattner 494a685449 Add support for removing invoke instructions
llvm-svn: 12858
2004-04-12 05:15:13 +00:00
Chris Lattner 08f201bee5 Stop printing Function*
llvm-svn: 12857
2004-04-12 04:06:56 +00:00
Chris Lattner d041dcd92f Simplify code a bit, and be sure to mark the external node as potentially throwing
llvm-svn: 12856
2004-04-12 04:06:38 +00:00
Chris Lattner a24f986333 Fix issues that the local allocator has dealing with instructions that implicitly use ST(0)
llvm-svn: 12855
2004-04-12 03:02:48 +00:00
Chris Lattner 2e2b0ceab9 No really, fix printing for LLC. I gotta get a way for CVS to whine at me if
I have unsaved emacs buffers, geeze...

llvm-svn: 12854
2004-04-12 01:52:04 +00:00
Chris Lattner ba1038e0f3 Correct printing for LLC and the encoding for the JIT
llvm-svn: 12853
2004-04-12 01:50:04 +00:00
Chris Lattner e407dbe9ff Use the fucomi[p] instructions to perform floating point comparisons instead
of the fucom[p][p] instructions.  This allows us to code generate this function

bool %test(double %X, double %Y) {
        %C = setlt double %Y, %X
        ret bool %C
}

... into:

test:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [%ESP + 12]
        fucomip %ST(1)
        fstp %ST(0)
        setb %AL
        movsx %EAX, %AL
        ret

where before we generated:

test:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [%ESP + 12]
        fucompp
**      fnstsw
**      sahf
        setb %AL
        movsx %EAX, %AL
        ret

The two marked instructions (which are the ones eliminated) are very bad,
because they serialize execution of the processor.  These instructions are
available on the PPRO and later, but since we already use cmov's we aren't
losing any portability.

I retained the old code for the day when we decide we want to support back
to the 386.

llvm-svn: 12852
2004-04-12 01:43:36 +00:00
Chris Lattner d1c7545322 Add support for the FUCOMIr instruction
llvm-svn: 12851
2004-04-12 01:39:15 +00:00
Chris Lattner 6c84d4ca44 Add two new instructions
llvm-svn: 12850
2004-04-12 01:38:55 +00:00
Chris Lattner 0fe57da8fa Fix a bug in my load/cast folding patch.
llvm-svn: 12849
2004-04-12 00:23:04 +00:00
Chris Lattner dc0105467a Adjust some comments, fix a bug in my previous patch
llvm-svn: 12848
2004-04-12 00:12:04 +00:00
Chris Lattner dfbb1d1cfe Disambiguate symbols after loop extraction so that we can diagnose a code
generator bug if multiple loops are extracted from a function.

llvm-svn: 12847
2004-04-11 23:52:35 +00:00
Chris Lattner 07c1c11511 On X86, casting an integer to floating point requires going through memory.
If the source of the cast is a load, we can just use the source memory location,
without having to create a temporary stack slot entry.

Before we code generated this:

double %int(int* %P) {
        %V = load int* %P
        %V2 = cast int %V to double
        ret double %V2
}

into:

int:
        sub %ESP, 4
        mov %EAX, DWORD PTR [%ESP + 8]
        mov %EAX, DWORD PTR [%EAX]
        mov DWORD PTR [%ESP], %EAX
        fild DWORD PTR [%ESP]
        add %ESP, 4
        ret

Now we produce this:

int:
        mov %EAX, DWORD PTR [%ESP + 4]
        fild DWORD PTR [%EAX]
        ret

... which is nicer.

llvm-svn: 12846
2004-04-11 23:21:26 +00:00
Chris Lattner 14243fb3b8 New testcase
llvm-svn: 12845
2004-04-11 23:18:30 +00:00
Chris Lattner d4af820aad Implement folding of loads into floating point operations. This implements:
test/Regression/CodeGen/X86/fp_load_fold.llx

llvm-svn: 12844
2004-04-11 22:05:45 +00:00
Chris Lattner fe94f0bf93 New testcase
llvm-svn: 12843
2004-04-11 22:05:16 +00:00
Chris Lattner dcb750f015 Unify all of the code for floating point +,-,*,/ into one function
llvm-svn: 12842
2004-04-11 21:23:56 +00:00
Chris Lattner 80ba401602 This implements folding of constant operands into floating point operations
for mul and div.

Instead of generating this:

test_divr:
        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [.CPItest_divr_0]
        fdivrp %ST(1)
        ret

We now generate this:

test_divr:
        fld QWORD PTR [%ESP + 4]
        fdivr QWORD PTR [.CPItest_divr_0]
        ret

This code desperately needs refactoring, which will come in the next
patch.

llvm-svn: 12841
2004-04-11 21:09:14 +00:00
Chris Lattner e1efbc7c6c Restructure the mul/div/rem handling code to follow the pattern the other
instructions use.  This doesn't change any functionality except that long
constant expressions of these operations will now magically start working.

llvm-svn: 12840
2004-04-11 20:56:28 +00:00
Chris Lattner f7ed7df539 Codegen FP adds and subtracts with a constant more efficiently, generating:
fld QWORD PTR [%ESP + 4]
        fadd QWORD PTR [.CPItest_add_0]

instead of:

        fld QWORD PTR [%ESP + 4]
        fld QWORD PTR [.CPItest_add_0]
        faddp %ST(1)

I also intend to do this for mul & div, but it appears that I have to
refactor a bit of code before I can do so.

This is tested by: test/Regression/CodeGen/X86/fp_constant_op.llx

llvm-svn: 12839
2004-04-11 20:26:20 +00:00
Chris Lattner b6e0b58fbc Add some new instructions
llvm-svn: 12838
2004-04-11 20:24:15 +00:00
Chris Lattner 9affe3e7df New testcase
llvm-svn: 12837
2004-04-11 20:24:01 +00:00
Chris Lattner 5b44472200 Relax assertion to make this function work with a broader class of instructions
llvm-svn: 12836
2004-04-11 20:21:06 +00:00
Chris Lattner 3f912a6f43 Two changes:
1. If an incoming argument is dead, don't load it from the stack
  2. Do not code gen noop copies at all (ie, cast int -> uint), not even to
     a move.  This should reduce register pressure for allocators that are
     unable to coallesce away these copies in some cases.

llvm-svn: 12835
2004-04-11 19:21:59 +00:00
Chris Lattner 5ec93a8678 Add another variant of the testcase
llvm-svn: 12834
2004-04-11 19:01:35 +00:00
Chris Lattner 403abb824f operator new & operator new[] do not kill any legal memory locations.
llvm-svn: 12833
2004-04-11 18:16:34 +00:00
Chris Lattner 74e5c31746 new testcase
llvm-svn: 12832
2004-04-11 16:47:15 +00:00
Chris Lattner c5fad355f8 Allow clients to be more efficient.
llvm-svn: 12831
2004-04-11 16:43:07 +00:00
Chris Lattner 9120ff3488 Make comments above APIs reflect what they should do.
llvm-svn: 12830
2004-04-11 16:42:50 +00:00
Chris Lattner a55bf865ea New method to allow more efficient clients
llvm-svn: 12829
2004-04-11 16:35:30 +00:00
Chris Lattner 24cf0200c7 Fix a bug in my select transformation
llvm-svn: 12826
2004-04-11 01:39:19 +00:00
Chris Lattner 192e326cd3 Add a missing break, which caused a crash in an obscure situation
llvm-svn: 12825
2004-04-11 01:29:30 +00:00
Chris Lattner f16fe7206c Update the value numbering interface.
llvm-svn: 12824
2004-04-10 22:33:34 +00:00
Chris Lattner ffdfe64ced Note to self: SAVE FILES!
llvm-svn: 12823
2004-04-10 22:32:47 +00:00
Chris Lattner 8e096ddeaf Add an interface to update value numbering
llvm-svn: 12822
2004-04-10 22:32:09 +00:00
Chris Lattner 623fba1107 Implement InstCombine/select.ll:test13*
llvm-svn: 12821
2004-04-10 22:21:27 +00:00
Chris Lattner 1f99df6d27 New testcases
llvm-svn: 12820
2004-04-10 22:21:14 +00:00
Chris Lattner cf4a996cba Implement InstCombine/add.ll:test20
Canonicalize add of sign bit constant into a xor

llvm-svn: 12819
2004-04-10 22:01:55 +00:00
Chris Lattner 825a00195d New testcase
llvm-svn: 12818
2004-04-10 22:01:27 +00:00
Chris Lattner 69c4900512 Rewrite the GCSE pass to be *substantially* simpler, a bit more efficient,
and a bit more powerful

llvm-svn: 12817
2004-04-10 21:11:11 +00:00
Chris Lattner f9d9665138 Fix spurious warning in release mode
llvm-svn: 12816
2004-04-10 19:15:56 +00:00
Chris Lattner d450df05ba Silence a spurious warning
llvm-svn: 12815
2004-04-10 18:32:01 +00:00
Chris Lattner d95ef7eff0 Simplify code a bit, and fix a bug that was breaking perlbmk
llvm-svn: 12814
2004-04-10 18:06:21 +00:00
Chris Lattner 7ebfe61dc1 Fix a bug in my checkin last night that was breaking programs using invoke.
llvm-svn: 12813
2004-04-10 16:53:29 +00:00
Chris Lattner 5093213c40 Fix previous patch
llvm-svn: 12811
2004-04-10 07:27:48 +00:00
Chris Lattner 6149ac8991 Correctly update counters
llvm-svn: 12810
2004-04-10 07:02:02 +00:00
Chris Lattner 027ccc1200 Add note
llvm-svn: 12809
2004-04-10 06:56:53 +00:00
Chris Lattner 4a1b03c773 Add a couple of more functions that cannot access memory (the intrinsics) and
don't write to memory

llvm-svn: 12808
2004-04-10 06:55:27 +00:00
Chris Lattner cfa1adcdb8 Simplify code a bit, and use alias analysis to allow us to delete unused
call and invoke instructions that are known to not write to memory.

llvm-svn: 12807
2004-04-10 06:53:09 +00:00
Chris Lattner 56471868e2 New testcases
llvm-svn: 12806
2004-04-10 06:52:20 +00:00
Chris Lattner f72a30b31c Clarify interface
llvm-svn: 12805
2004-04-10 06:11:29 +00:00
Chris Lattner 5393e11318 Create the output directory if it's not already there
llvm-svn: 12804
2004-04-10 06:03:22 +00:00
Chris Lattner d777677665 Simplify cfg now eliminates all of the branches in this testcase
llvm-svn: 12803
2004-04-09 23:50:29 +00:00