Commit Graph

710 Commits

Author SHA1 Message Date
Reid Spencer
21cb67e16a bug 122:
- Replace ConstantPointerRef usage with GlobalValue usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14947 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:31:05 +00:00
Reid Spencer
48dc46a512 bug 122:
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14946 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-18 00:29:57 +00:00
Chris Lattner
80b2d6c8c4 This patch was contributed by Daniel Berlin!
Speed up SCCP substantially by processing overdefined values quickly.  This
patch speeds up SCCP by about 30-40% on large testcases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14861 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-15 23:36:43 +00:00
Chris Lattner
2fc1230dd6 Fixes working towards PR341
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14839 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-15 01:50:47 +00:00
Chris Lattner
b89e071aea Factor some code to handle "load (constantexpr cast foo)" just like
"load (cast foo)".  This allows us to compile C++ code like this:

class Bclass {
  public: virtual int operator()() { return 666; }
};

class Dclass: public Bclass {
  public: virtual int operator()() { return 667; }
} ;

int main(int argc, char** argv) {
  Dclass x;
  return x();
}

Into this:

int %main(int %argc, sbyte** %argv) {
entry:
        call void %__main( )
        ret int 667
}

Instead of this:

int %main(int %argc, sbyte** %argv) {
entry:
        %x = alloca "struct.std::bad_typeid"            ; <"struct.std::bad_typeid"*> [#uses=3]
        call void %__main( )
        %tmp.1.i.i = getelementptr "struct.std::bad_typeid"* %x, uint 0, uint 0, uint 0         ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Bclass, int 0, long 2), int (...)*** %tmp.1.i.i
        %tmp.3.i = getelementptr "struct.std::bad_typeid"* %x, int 0, uint 0, uint 0            ; <int (...)***> [#uses=1]
        store int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2), int (...)*** %tmp.3.i
        %tmp.5 = load int ("struct.std::bad_typeid"*)** cast (int (...)** getelementptr ([3 x int (...)*]*  %vtable for Dclass, int 0, long 2) to int
("struct.std::bad_typeid"*)**)          ; <int ("struct.std::bad_typeid"*)*> [#uses=1]
        %tmp.6 = call int %tmp.5( "struct.std::bad_typeid"* %x )                ; <int> [#uses=1]
	ret int %tmp.6
        ret int 0
}

In order words, we now resolve the virtual function call.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14783 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-13 01:49:43 +00:00
Chris Lattner
fae1010218 Check to make sure types are sized before calling getTypeSize on them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14649 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 19:28:42 +00:00
Brian Gaeke
08cc64ebfe It doesn't matter what the 2nd operand is; if the GEP has 2 operands and
the first is a zero, we should leave it alone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14648 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 19:24:47 +00:00
Brian Gaeke
10585d92da Add helper function.
Don't touch GEPs for which DecomposeArrayRef is not going to do anything
special (e.g., < 2 indices, or 2 indices and the last one is a constant.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14647 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 18:15:39 +00:00
Chris Lattner
3571b72606 Implement rem.ll:test3
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14640 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:38:18 +00:00
Chris Lattner
1e3564ef05 Fix a minor bug where we would go into infinite loops on some constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14638 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:11:42 +00:00
Chris Lattner
5b73c08896 Implement InstCombine/sub.ll:test15: X % -Y === X % Y
Also, remove X % -1 = 0, because it's not true for unsigneds, and the
signed case is superceeded by this new handling.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14637 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-06 07:01:22 +00:00
Reid Spencer
954da37bb4 Add #include <iostream> since Value.h does not #include it any more.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14622 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-04 12:19:56 +00:00
Chris Lattner
46238a6150 Implement add.ll:test22, a common case in MSIL files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14587 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-03 00:26:11 +00:00
Chris Lattner
cf27afb64e Do not call getTypeSize on a type that has no size
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14584 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-02 22:55:47 +00:00
Brian Gaeke
1c4b6de4e7 Get rid of a dead variable, and fix a typo in a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14560 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-02 05:30:01 +00:00
Brian Gaeke
a9160a064f Make this pass use a more specific debug message than "Processing:".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14541 91177308-0d34-0410-b5e6-96231b3b80d8
2004-07-01 19:27:10 +00:00
Chris Lattner
15d58b638a Implement InstCombine/add.ll:test21
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14443 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-27 22:51:36 +00:00
Chris Lattner
9dc1b2ae9b New constant expression lowering pass to simplify your instruction selection needs.
Contributed by Vladimir Prus!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14399 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-25 07:48:09 +00:00
Chris Lattner
a25502acd7 Two fixes. First, stop using the ugly shouldSubstituteIndVar method.
Second, disable substitution of quadratic addrec expressions to avoid putting
multiplies in loops!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14358 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-24 06:49:18 +00:00
Chris Lattner
c5c5e6afe5 Make use of BinaryOperator::create* methods to shrinkify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14262 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-20 05:04:01 +00:00
Chris Lattner
56b7ee20da Now that dominator tree children are built in determinstic order, this horrible code
can go away


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14254 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 20:23:35 +00:00
Chris Lattner
2b994c7206 Fix a nasty bug, noticed by Reid
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14249 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 18:15:50 +00:00
Chris Lattner
edb8433c91 Fix one source of nondeterminism in the -licm pass: the hoist pass
was processing blocks in whatever order they happened to end up in the
dominator tree data structure.  Force an ordering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14248 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 08:56:43 +00:00
Chris Lattner
8430a4545c Do not loop over uses as we delete them. This causes iterators to be
invalidated out from under us.  This bug goes back to revision 1.1: scary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14242 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-19 02:02:22 +00:00
Chris Lattner
5b62aa743d Implement Transforms/InstCombine/and.ll:test17, a common case that
occurs due to unordered comparison macros in math.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14221 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-18 06:07:51 +00:00
Chris Lattner
5dd04027c7 Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
Delete two functions that are now methods on the Type class


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14200 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 18:16:02 +00:00
Brian Gaeke
802daf8b7d Fix typo in DEBUG printout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14196 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-17 07:26:52 +00:00
Chris Lattner
3285a6f426 Fix a bug in my checkin from last night that caused miscompilations of
186.crafty, fhourstones and 132.ijpeg.

Bugpoint makes really nasty miscompilations embarassingly easy to find.  It
narrowed it down to the instcombiner and this testcase (from fhourstones):

bool %l7153_l4706_htstat_loopentry_2E_4_no_exit_2E_4(int* %i, [32 x int]* %works, int* %tmp.98.out) {
newFuncRoot:
        %tmp.96 = load int* %i          ; <int> [#uses=1]
        %tmp.97 = getelementptr [32 x int]* %works, long 0, int %tmp.96         ; <int*> [#uses=1]
        %tmp.98 = load int* %tmp.97             ; <int> [#uses=2]
        %tmp.99 = load int* %i          ; <int> [#uses=1]
        %tmp.100 = and int %tmp.99, 7           ; <int> [#uses=1]
        %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=2]
        %tmp.102 = cast bool %tmp.101 to int            ; <int> [#uses=0]
        br bool %tmp.101, label %codeRepl4.exitStub, label %codeRepl3.exitStub

codeRepl4.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool true

codeRepl3.exitStub:             ; preds = %newFuncRoot
        store int %tmp.98, int* %tmp.98.out
        ret bool false
}

... which only has one combination performed on it:

$ llvm-as < t.ll | opt -instcombine -debug | llvm-dis
IC: Old =       %tmp.101 = seteq int %tmp.100, 7                ; <bool> [#uses=1]
    New =       setne int %tmp.100, 0           ; <bool>:<badref> [#uses=0]
IC: MOD =       br bool %tmp.101, label %codeRepl3.exitStub, label %codeRepl4.exitStub
IC: MOD =       %tmp.97 = getelementptr [32 x int]* %works, uint 0, int %tmp.96         ; <int*> [#uses=1]

It doesn't get much better than this.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14109 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:33:20 +00:00
Chris Lattner
448c323cba More minor cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14108 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:12:35 +00:00
Chris Lattner
48595f18cf Eliminate many occurrances of Instruction::
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14107 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-10 02:07:29 +00:00
Chris Lattner
457dd829ad Implement InstCombine/select.ll:test15*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14095 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 07:59:58 +00:00
Chris Lattner
f523d06816 Be more careful about the order we put stuff onto the worklist. This allow us to
collapse this:
bool %le(int %A, int %B) {
        %c1 = setgt int %A, %B
        %tmp = select bool %c1, int 1, int 0
        %c2 = setlt int %A, %B
        %result = select bool %c2, int -1, int %tmp
        %c3 = setle int %result, 0
        ret bool %c3
}

into:

bool %le(int %A, int %B) {
        %c3 = setle int %A, %B          ; <bool> [#uses=1]
        ret bool %c3
}

which is handy, because the Java FE makes these sequences all over the place.

This is tested as: test/Regression/Transforms/InstCombine/JavaCompare.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14086 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 05:08:07 +00:00
Chris Lattner
2be51ae22d Implement select.ll:test14*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14083 91177308-0d34-0410-b5e6-96231b3b80d8
2004-06-09 04:24:29 +00:00
Chris Lattner
e1368aef23 Fix InstCombine/load.ll & PR347.
This code hadn't been updated after the "structs with more than 256 elements"
related changes to the GEP instruction.  Also it was not handling the
ConstantAggregateZero class.

Now it does!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13834 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-27 17:30:27 +00:00
Reid Spencer
c8a1fcdb48 Remove unused header file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13750 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:36 +00:00
Reid Spencer
3f0635e012 Make this pass simply invoke SymbolTable::strip().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13749 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 08:51:25 +00:00
Chris Lattner
3c6a0d4ae2 Implement InstCombine:shift.ll:test16, which turns (X >> C1) & C2 != C3
into (X & (C2 << C1)) != (C3 << C1), where the shift may be either left or
right and the compare may be any one.

This triggers 1546 times in 176.gcc alone, as it is a common pattern that
occurs for bitfield accesses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 06:32:08 +00:00
Chris Lattner
a710ddc9c4 Implement instcombine/cast.ll:test16:
Canonicalize cast X to bool into a setne instruction


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13736 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-25 04:29:21 +00:00
Chris Lattner
f52988a92d Spelling people's names right is kinda important
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:27:29 +00:00
Chris Lattner
2741c97104 Adjust to the changes in the AliasSetTracker interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13690 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:20:19 +00:00
Chris Lattner
057f78ab4e Add support for replacement of formal arguments with simpler expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13689 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:55 +00:00
Chris Lattner
08005dfdc9 Implement the -lowergc pass which is used by code generators (like the CBE)
that do not have builtin support for garbage collection.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13688 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-23 21:19:22 +00:00
Chris Lattner
fa28bb4601 This was not meant to be committed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13565 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:56:34 +00:00
Chris Lattner
82fec4e31d Fix a nasty bug that caused us to unroll EXTREMELY large loops due to overflow
in the size calculation.

This is not something you want to see:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - UNROLLING!

The problem was that 2*2147483648 == 0.

Now we get:
Loop Unroll: F[main] Loop %no_exit Loop Size = 2 Trip Count = 2147483648 - TOO LARGE: 4294967296>100

Thanks to some anonymous person playing with the demo page that repeatedly
caused zion to go into swapping land.  That's one way to ensure you'll get
a quick bugfix.  :)

Testcase here: Transforms/LoopUnroll/2004-05-13-DontUnrollTooMuch.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13564 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-13 20:43:31 +00:00
Chris Lattner
be97b4e9ab Fix stupid bug in my checkin yesterday
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13429 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-08 22:41:42 +00:00
Chris Lattner
620ce14666 Implement folding of GEP's like:
%tmp.0 = getelementptr [50 x sbyte]* %ar, uint 0, int 5         ; <sbyte*> [#uses=2]
        %tmp.7 = getelementptr sbyte* %tmp.0, int 8             ; <sbyte*> [#uses=1]

together.  This patch actually allows us to simplify and generalize the code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 22:09:22 +00:00
Chris Lattner
546516c3c0 Fix PR336: The instcombine pass asserts when visiting load instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-07 15:35:56 +00:00
Chris Lattner
b9110c61fb Do not mark instructions in unreachable sections of the function as live.
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13349 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 17:00:46 +00:00
Chris Lattner
32ed46b36e Minor efficiency tweak, suggested by Patrick Meredith
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13341 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-04 15:19:33 +00:00
Chris Lattner
00d513182d Make sure to reprocess instructions used by deleted instructions to avoid
missing opportunities for combination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13309 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:27:23 +00:00
Chris Lattner
216d4d85fd Make sure the instruction combiner doesn't lose track of instructions
when replacing them, missing the opportunity to do simplifications


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13308 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:19:52 +00:00
Chris Lattner
c1526a9da1 Fix a major pessimization in the instcombiner. If an allocation instruction
is only used by a cast, and the casted type is the same size as the original
allocation, it would eliminate the cast by folding it into the allocation.

Unfortunately, it was placing the new allocation instruction right before
the cast, which could pull (for example) alloca instructions into the body
of a function.  This turns statically allocatable allocas into expensive
dynamically allocated allocas, which is bad bad bad.

This fixes the problem by placing the new allocation instruction at the same
place the old one was, duh. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13289 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-30 04:37:52 +00:00
Chris Lattner
6ffe551f65 Changes to fix up the inst_iterator to pass to boost iterator checks. This
patch was graciously contributed by Vladimir Prus.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13185 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-27 15:13:33 +00:00
Chris Lattner
83a2e6e4a1 Instcombine X/-1 --> 0-X
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13172 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-26 14:01:59 +00:00
Chris Lattner
4a7553e2da Move the scev expansion code into this pass, where it belongs. There is
still room for cleanup, but at least the code modification is out of the
analysis now.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13135 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 21:29:48 +00:00
Chris Lattner
b4782d13d1 Disable a previous patch that was causing indvars to loop infinitely :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13108 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 15:12:36 +00:00
Chris Lattner
fcb81f5f4c Fix an extremely serious thinko I made in revision 1.60 of this file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13106 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-22 14:59:40 +00:00
Chris Lattner
1363e85df7 Implement a todo, rewriting all possible scev expressions inside of the
loop.  This eliminates the extra add from the previous case, but it's
not clear that this will be a performance win overall.  Tommorows test
results will tell. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13103 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 23:36:08 +00:00
Chris Lattner
4e5f03602c This code really wants to iterate over the OPERANDS of an instruction, not
over its USES.  If it's dead it doesn't have any uses!  :)

Thanks to the fabulous and mysterious Bill Wendling for pointing this out.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13102 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 22:29:37 +00:00
Chris Lattner
5d461d20ae Implement a fixme. The helps loops that have induction variables of different
types in them.  Instead of creating an induction variable for all types, it
creates a single induction variable and casts to the other sizes.  This generates
this code:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=4]
***     %j.0.0 = cast uint %indvar to short             ; <short> [#uses=1]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %j.0.0, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.2, label %no_exit, label %loopexit

instead of:

no_exit:                ; preds = %entry, %no_exit
        %indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ]          ; <ushort> [#uses=2]
***     %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %indvar = cast uint %indvar to int              ; <int> [#uses=1]
        %indvar = cast ushort %indvar to short          ; <short> [#uses=1]
        %tmp.7 = getelementptr short* %P, uint %indvar          ; <short*> [#uses=1]
        store short %indvar, short* %tmp.7
        %inc.0 = add int %indvar, 1             ; <int> [#uses=2]
        %tmp.2 = setlt int %inc.0, %N           ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1
***     %indvar.next = add ushort %indvar, 1
        br bool %tmp.2, label %no_exit, label %loopexit

This is an improvement in register pressure, but probably doesn't happen that
often.

The more important fix will be to get rid of the redundant add.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13101 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 22:22:01 +00:00
Chris Lattner
c99acc3709 Fix PR325
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13081 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-20 20:26:03 +00:00
Chris Lattner
18f16094c2 Initial checkin of a simple loop unswitching pass. It still needs work,
but it's a start, and seems to do it's basic job.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13068 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-19 18:07:02 +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
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
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
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
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
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
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
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
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
Chris Lattner
006118fe8c Fix some of the strange CBE-only failures that happened last night.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12980 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 06:03:17 +00:00
Chris Lattner
d244057a48 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12968 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 20:26:22 +00:00
Chris Lattner
59fdaeeae8 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12961 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-15 15:21:43 +00:00
Chris Lattner
d9955aaa61 ADd a trivial instcombine: load null -> null
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12940 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-14 03:28:36 +00:00
Chris Lattner
58b7b08ad7 Add SCCP support for constant folding calls, implementing:
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-13 19:43:54 +00:00
Chris Lattner
4647b7cd69 Constant propagation should remove the dead instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12917 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 19:28:20 +00:00
Chris Lattner
1708d12916 Add support for removing invoke instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12858 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-12 05:15:13 +00:00
Chris Lattner
fbede52af4 Fix a bug in my select transformation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12826 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-11 01:39:19 +00:00
Chris Lattner
adb7c0de39 Update the value numbering interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12824 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:33:34 +00:00
Chris Lattner
d76956d444 Implement InstCombine/select.ll:test13*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12821 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:21:27 +00:00
Chris Lattner
66331a4e33 Implement InstCombine/add.ll:test20
Canonicalize add of sign bit constant into a xor


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12819 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 22:01:55 +00:00
Chris Lattner
38e66bd9d1 Rewrite the GCSE pass to be *substantially* simpler, a bit more efficient,
and a bit more powerful


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12817 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 21:11:11 +00:00
Chris Lattner
326c0f3013 Fix spurious warning in release mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12816 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 19:15:56 +00:00
Chris Lattner
a5f4103931 Simplify code a bit, and fix a bug that was breaking perlbmk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12814 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 18:06:21 +00:00
Chris Lattner
562cb66b84 Fix a bug in my checkin last night that was breaking programs using invoke.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12813 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 16:53:29 +00:00
Chris Lattner
27c694bacb Fix previous patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12811 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 07:27:48 +00:00
Chris Lattner
17177601fb Correctly update counters
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12810 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 07:02:02 +00:00
Chris Lattner
ede6ac60a5 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12807 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-10 06:53:09 +00:00
Chris Lattner
e576b91948 Implement select.ll:test12*
This transforms code like this:

   %C = or %A, %B
   %D = select %cond, %C, %A
into:
   %C = select %cond, %B, 0
   %D = or %A, %C

Since B is often a constant, the select can often be eliminated.  In any case,
this reduces the usage count of A, allowing subsequent optimizations to happen.

This xform applies when the operator is any of:
  add, sub, mul, or, xor, and, shl, shr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12800 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 23:46:01 +00:00
Chris Lattner
2eefe518de Fold binary operators with a constant operand into select instructions
that have a constant operand.  This implements
add.ll:test19, shift.ll:test15*, and others that are not tested


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12794 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 19:05:30 +00:00
Chris Lattner
82e14fe168 Implement select.ll:test11
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12793 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 18:19:44 +00:00
Chris Lattner
f499eaca36 Implement InstCombine/cast-propagate.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12784 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 20:39:49 +00:00
Chris Lattner
0c199a7628 Implement InstCombine/select.ll:test[7-10]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12769 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 04:43:23 +00:00
Chris Lattner
cb69a4ed64 Implement test/Regression/Transforms/InstCombine/getelementptr_index.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12762 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-07 18:38:20 +00:00
Chris Lattner
548f47efb0 Fix a bug in yesterdays checkins which broke siod. siod is a great testcase! :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12659 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 16:02:41 +00:00
Chris Lattner
15a76c0b35 Fix InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12658 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 02:10:19 +00:00
Chris Lattner
28977af72a Support getelementptr instructions which use uint's to index into structure
types and can have arbitrary 32- and 64-bit integer types indexing into
sequential types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12653 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 01:30:19 +00:00
Chris Lattner
40bf8b48cd Rewrite the indvars pass to use the ScalarEvolution analysis.
This also implements some new features for the indvars pass, including
linear function test replacement, exit value substitution, and it works with
a much more general class of induction variables and loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12620 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-02 20:24:31 +00:00
Chris Lattner
c32b30a429 Implement select.ll:test[3-6]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12544 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-30 19:37:13 +00:00
Chris Lattner
4df1b8aa26 X % -1 == X % 1 == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12520 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-26 16:11:24 +00:00
Chris Lattner
ebd985cb87 Two changes:
#1 is to unconditionally strip constantpointerrefs out of
instruction operands where they are absolutely pointless and inhibit
optimization.  GRRR!

#2 is to implement InstCombine/getelementptr_const.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12519 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-25 22:59:29 +00:00
Chris Lattner
7c881dffc9 Teach the optimizer to delete zero sized alloca's (but not mallocs!)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12507 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-19 06:08:10 +00:00
Chris Lattner
e911979650 Be more accurate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12464 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-17 01:59:27 +00:00
Chris Lattner
50eafbc828 Fix bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12458 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:36:49 +00:00
Chris Lattner
24ad00db5a Okay, so there is no reasonable way for tail duplication to update SSA form,
as it is making effectively arbitrary modifications to the CFG and we don't
have a domset/domfrontier implementations that can handle the dynamic updates.
Instead of having a bunch of code that doesn't actually work in practice,
just demote any potentially tricky values to the stack (causing the problem
to go away entirely).  Later invocations of mem2reg will rebuild SSA for us.

This fixes all of the major performance regressions with tail duplication
from LLVM 1.1.  For example, this loop:

---
int popcount(int x) {
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}
---
Used to be compiled into:

int %popcount(int %X) {
entry:
	br label %loopentry

loopentry:		; preds = %entry, %no_exit
	%x.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]		; <int> [#uses=3]
	%result.1.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]		; <int> [#uses=2]
	%tmp.1 = seteq int %x.0, 0		; <bool> [#uses=1]
	br bool %tmp.1, label %loopexit, label %no_exit

no_exit:		; preds = %loopentry
	%tmp.4 = and int %x.0, 1		; <int> [#uses=1]
	%tmp.6 = add int %tmp.4, %result.1.0		; <int> [#uses=1]
	%tmp.9 = shr int %x.0, ubyte 1		; <int> [#uses=1]
	br label %loopentry

loopexit:		; preds = %loopentry
	ret int %result.1.0
}

And is now compiled into:

int %popcount(int %X) {
entry:
        br label %no_exit

no_exit:                ; preds = %entry, %no_exit
        %x.0.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]          ; <int> [#uses=2]
        %result.1.0.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]             ; <int> [#uses=1]
        %tmp.4 = and int %x.0.0, 1              ; <int> [#uses=1]
        %tmp.6 = add int %tmp.4, %result.1.0.0          ; <int> [#uses=2]
        %tmp.9 = shr int %x.0.0, ubyte 1                ; <int> [#uses=2]
        %tmp.1 = seteq int %tmp.9, 0            ; <bool> [#uses=1]
        br bool %tmp.1, label %loopexit, label %no_exit

loopexit:               ; preds = %no_exit
        ret int %tmp.6
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12457 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:29:09 +00:00
Chris Lattner
a2f652d420 Do not try to optimize PHI nodes with incredibly high degree. This reduces SCCP
time from 615s to 1.49s on a large testcase that has a gigantic switch statement
that all of the blocks in the function go to (an intepreter).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12442 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:49:59 +00:00
Chris Lattner
4bebf08d15 Do not copy gigantic switch instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12441 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:45:22 +00:00
Chris Lattner
46234fd97f Add counters for the number of calls elimianted
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12420 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 05:46:59 +00:00
Chris Lattner
118dd0ce3d Implement LICM of calls in simple cases. This is sufficient to move around
sin/cos/strlen calls and stuff.  This implements:
  LICM/call_sink_pure_function.ll
  LICM/call_sink_const_function.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 04:11:30 +00:00
Chris Lattner
0cea42a560 Add some debugging output
Fix InstCombine/2004-03-13-InstCombineInfLoop.ll which caused an infinite
loop compiling (I think) povray.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12365 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 23:54:27 +00:00
Chris Lattner
bfe492b5c2 Implement sub.ll:test14
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12355 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-13 00:11:49 +00:00
Chris Lattner
9c2906744a Implement InstCombine/sub.ll:test12 & test13
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12353 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 23:53:13 +00:00
Chris Lattner
6e32372fcd Add sccp support for select instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12318 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:52:44 +00:00
Chris Lattner
3d69f46d64 Add trivial optimizations for select instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12317 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-12 05:52:32 +00:00
Chris Lattner
c76d80342e Since 'load null' is undefined, we can make it do whatever we want. Returning
a zero value is the most likely way to cause further simplification, so we do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12197 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-07 22:16:24 +00:00
Chris Lattner
99cca7d3aa Disable tail duplication in a case that breaks on Olden/tsp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12021 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-01 01:12:13 +00:00
Chris Lattner
4279f3c984 Fix PR255: [tailduplication] Single basic block loops are very rare
Note that this is a band-aid put over a band-aid.  This just undisables
tail duplication in on very specific case that it seems to work in.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11989 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-29 06:41:20 +00:00
Chris Lattner
7bcc0e7fff Rename AddUsesToWorkList -> AddUsersToWorkList, as that is what it does.
Create a new AddUsesToWorkList method
optimize memmove/set/cpy of zero bytes to a noop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11941 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 05:22:00 +00:00
Chris Lattner
6160e85201 Turn 'free null' into nothing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11940 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-28 04:57:37 +00:00
Chris Lattner
a0ebcebc06 Implement test/Regression/Transforms/InstCombine/canonicalize_branch.ll
This is a really minor thing, but might help out the 'switch statement induction'
code in simplifycfg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11900 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-27 06:27:46 +00:00
Chris Lattner
d38f208cd9 Fix a faulty optimization on FP values
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11801 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-24 18:10:14 +00:00
Chris Lattner
d8864ce766 Generate much more efficient code in programs like pifft
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11775 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 21:46:58 +00:00
Chris Lattner
077a373791 Fix a small typeo in my checkin last night that broke vortex and other programs :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11774 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 21:46:42 +00:00
Chris Lattner
8adac75298 Fix InstCombine/2004-02-23-ShiftShiftOverflow.ll
Also, turn 'shr int %X, 1234' into 'shr int %X, 31'


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11768 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 20:30:06 +00:00
Chris Lattner
c5943fb186 Implement cast.ll::test14/15
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11742 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 07:16:20 +00:00
Chris Lattner
4cb170cc6e Refactor some code. In the mul - setcc folding case, we really care about
whether this is the sign bit or not, so check unsigned comparisons as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11740 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 06:38:22 +00:00
Chris Lattner
fed58fd72e Implement mul.ll:test11
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11737 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 06:00:11 +00:00
Chris Lattner
45aaafef49 Implement "strength reduction" of X <= C and X >= C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11735 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 05:47:48 +00:00
Chris Lattner
fb54b2b744 Implement InstCombine/mul.ll:test10, which is a case that occurs when dealing
with "predication"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11734 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-23 05:39:21 +00:00
Chris Lattner
c6bd195336 Implement Transforms/InstCombine/cast.ll:test13, a case which occurs in a
hot 164.gzip loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11702 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-22 05:25:17 +00:00
Chris Lattner
7059f2e76b Fold PHI nodes of constants which are only used by a single cast. This implements
phi.ll:test4


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11494 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 05:07:08 +00:00
Chris Lattner
26ca7e145e Teach LLVM to unravel the "swap idiom". This implements:
Regression/Transforms/InstCombine/xor.ll:test20


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11492 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 03:54:20 +00:00
Chris Lattner
c317d39887 Implement Transforms/InstCombine/xor.ll:test19
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-16 01:20:27 +00:00
Chris Lattner
de512b5b2e Adjustments to support the new ConstantAggregateZero class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11474 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-15 05:55:15 +00:00
Chris Lattner
5f55aaf0f0 Remove obsolete comment. Unreachable blocks will automatically be left at the
end of the function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11313 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 05:20:50 +00:00
Chris Lattner
206805e172 Add an _embarassingly simple_ implementation of basic block layout. This is
more of a testcase for profiling information than anything that should reasonably
be used, but it's a starting point.  When I have more time I will whip this into
better shape.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11311 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-11 04:53:20 +00:00
Chris Lattner
aeb2a1d708 rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11202 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-08 21:44:31 +00:00
Chris Lattner
79fc865ccb Add debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11139 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-05 22:33:19 +00:00
Chris Lattner
c24a076c6a Adjust to the new BasicBlock ctor, which requires a function parameter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11114 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-04 03:58:28 +00:00
Chris Lattner
0517e72096 Disable (x - (y - z)) => (x + (z - y)) optimization for floating point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11083 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-02 20:09:56 +00:00
Chris Lattner
529429224c Update comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11082 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-02 20:09:22 +00:00
Chris Lattner
c23396e8de Disable tail duplication in any "hard" cases, where it might break SSA form.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11052 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-01 06:32:28 +00:00
Chris Lattner
e400a0976f Fix the count of the number of instructions removed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11049 91177308-0d34-0410-b5e6-96231b3b80d8
2004-02-01 05:15:07 +00:00