Alkis Evlogimenos
d59cebf87a
Fix loop condition so that we don't decrement off the beginning of the
...
list.
llvm-svn: 16440
2004-09-20 06:42:58 +00:00
Chris Lattner
3e86084641
Prototype these functions more accurately
...
llvm-svn: 16432
2004-09-20 04:43:15 +00:00
Chris Lattner
e6f13093e6
Make isSafeToLoadUnconditionally a bit smarter, implementing PR362 and
...
Regression/Transforms/InstCombine/CPP_min_max.llx
llvm-svn: 16409
2004-09-19 19:18:10 +00:00
Chris Lattner
f62ea8ef4b
Make instruction combining a bit more aggressive in the face of volatile
...
loads, and implement two new transforms: InstCombine/load.ll:test[56].
llvm-svn: 16404
2004-09-19 18:43:46 +00:00
Reid Spencer
6614946443
Convert code to compile with vc7.1.
...
Patch contributed by Paolo Invernizzi. Thanks Paolo!
llvm-svn: 16368
2004-09-15 17:06:42 +00:00
Chris Lattner
f11216d24f
Fix a bug in the previous checkin that broke 255.vortex
...
llvm-svn: 16355
2004-09-15 02:34:40 +00:00
Chris Lattner
a346578d92
Make sure to update alias analysis information as we transform the function.
...
This fixes PR420 and Regression/Transforms/LICM/2004-09-14-AliasAnalysisInvalidate.llx
llvm-svn: 16348
2004-09-15 01:04:07 +00:00
Chris Lattner
f41b80a05f
Remove a long-dead pass. Actually, this pass was never used at all.
...
llvm-svn: 16337
2004-09-14 16:33:01 +00:00
Alkis Evlogimenos
a5c04ee50f
Fixes to make LLVM compile with vc7.1.
...
Patch contributed by Paolo Invernizzi!
llvm-svn: 16152
2004-09-03 18:19:51 +00:00
Reid Spencer
7c16caa336
Changes For Bug 352
...
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.
llvm-svn: 16137
2004-09-01 22:55:40 +00:00
Reid Spencer
f39f66e3ef
Initial checkin of a pass to lower packed operations to scalars operations.
...
This also registers the pass with opt with a -lower-packed command line
option.
Patch contributed by Brad Jones.
llvm-svn: 15987
2004-08-21 21:39:24 +00:00
Chris Lattner
4456da6a4c
Fix InstCombine/2004-08-10-BoolSetCC.ll, a bug that is miscompiling
...
176.gcc. Note that this is apparently not the only bug miscompiling gcc
though. :(
llvm-svn: 15639
2004-08-11 00:50:51 +00:00
Chris Lattner
8e7260652b
Fix InstCombine/2004-08-09-RemInfLoop.llx
...
This should go into the 1.3 branch
llvm-svn: 15593
2004-08-09 21:05:48 +00:00
Alkis Evlogimenos
832437255d
Stop using getValues().
...
llvm-svn: 15487
2004-08-04 08:44:43 +00:00
Chris Lattner
7aa2d4747a
Fix a regression in InstCombine/xor.ll
...
llvm-svn: 15410
2004-08-01 19:42:59 +00:00
Misha Brukman
9c003d8f65
Fix De Morgan's name.
...
llvm-svn: 15343
2004-07-30 12:50:08 +00:00
Chris Lattner
d4252a7c64
Start using the PatternMatcher a bit.
...
llvm-svn: 15342
2004-07-30 07:50:03 +00:00
Misha Brukman
63b38bd2ed
Fix #includes of i*.h => Instructions.h as per PR403.
...
llvm-svn: 15334
2004-07-29 17:30:56 +00:00
Misha Brukman
2b3387a6d9
Fix #includes of i*.h => Instructions.h as per PR403.
...
llvm-svn: 15328
2004-07-29 17:05:13 +00:00
Robert Bocchino
7b5b86cd0f
This change fixed a bug in the function visitMul. The prior version
...
assumed that a constant on the RHS of a multiplication was either an
IntConstant or an FPConstant. It checked for an IntConstant and then,
if it did not find one, did a hard cast to an FPConstant. That code
would crash if the RHS were a ConstantExpr that was neither an
IntConstant nor an FPConstant. This version replaces the hard cast
with a dyn_cast. It performs the same way for IntConstants and
FPConstants but does nothing, instead of crashing, for constant
expressions.
The regression test for this change is 2004-07-27-ConstantExprMul.ll.
llvm-svn: 15291
2004-07-27 21:02:21 +00:00
Brian Gaeke
38b79e8fbc
Make the create...() functions for some of these passes return a FunctionPass *.
...
llvm-svn: 15276
2004-07-27 17:43:21 +00:00
Chris Lattner
50eb771d37
Fix hoisting of void typed values, e.g. calls
...
llvm-svn: 15263
2004-07-27 07:38:32 +00:00
Chris Lattner
f29807169a
Implement DeadStoreElim/alloca.llx by observing that allocas are dead at the
...
end of the function (either return or unwind)
llvm-svn: 15232
2004-07-26 06:14:11 +00:00
Chris Lattner
e5ad26dbb3
Throttle back indvar substitution from creating multiplies in loops. This is bad bad bad.
...
llvm-svn: 15227
2004-07-26 02:47:12 +00:00
Chris Lattner
7b25bcdf52
* Substantially simplify how free instructions are handled (potentially fixing
...
a bug in DSE).
* Delete dead operand uses iteratively instead of recursively, using a
SetVector.
* Defer deletion of dead operand uses until the end of processing, which means
we don't have to bother with updating the AliasSetTracker. This speeds up
DSE substantially.
llvm-svn: 15204
2004-07-25 11:09:56 +00:00
Chris Lattner
4c1c1ac7e4
Free instructions kill values too. This implements DeadStoreElim/free.llx
...
llvm-svn: 15199
2004-07-25 07:58:38 +00:00
Chris Lattner
bad6478b00
obvious fix
...
llvm-svn: 15162
2004-07-24 07:51:27 +00:00
Chris Lattner
3844c300de
This is a trivial dead store elimination pass. It very very simple and
...
can be improved in many ways. But: stop laughing, even with -basicaa it
deletes 15% of the stores in 252.eon :)
llvm-svn: 15101
2004-07-22 08:00:28 +00:00
Chris Lattner
51f7c9e56d
Update GC intrinsics to take a pointer to the object as well as a pointer
...
to the field being updated. Patch contributed by Tobias Nurmiranta
llvm-svn: 15097
2004-07-22 05:51:13 +00:00
Chris Lattner
d8f5e2ccac
* Further cleanup.
...
* Test for whether bits are shifted out during the optzn.
If so, the fold is illegal, though it can be handled explicitly for setne/seteq
This fixes the miscompilation of 254.gap last night, which was a latent bug
exposed by other optimizer improvements.
llvm-svn: 15085
2004-07-21 20:14:10 +00:00
Chris Lattner
1638de4499
Make cast-cast code a bit more defensive
...
"simplify" a bit of code for comparison/and folding
llvm-svn: 15082
2004-07-21 19:50:44 +00:00
Chris Lattner
4fbad968f8
Remove special casing of pointers and treat them generically as integers of
...
the appopriate size. This gives us the ability to eliminate int -> ptr -> int
llvm-svn: 15063
2004-07-21 04:27:24 +00:00
Chris Lattner
11ffd59e37
Implement Transforms/InstCombine/IntPtrCast.ll
...
llvm-svn: 15029
2004-07-20 05:21:00 +00:00
Chris Lattner
44d0b9502a
Implement InstCombine/GEPIdxCanon.ll
...
llvm-svn: 15024
2004-07-20 01:48:15 +00:00
Chris Lattner
4e2dbc6b4a
Rewrite cast->cast elimination code completely based on the information we
...
actually care about. Someday when the cast instruction is gone, we can do
better here, but this will do for now. This implements
instcombine/cast.ll:test17/18 as well.
llvm-svn: 15018
2004-07-20 00:59:32 +00:00
Chris Lattner
f3edc49ae2
Minor cleanup, no functionality change
...
llvm-svn: 14972
2004-07-18 18:59:44 +00:00
Reid Spencer
f0a5bcaae4
Delete a redundant if branch.
...
llvm-svn: 14967
2004-07-18 08:34:52 +00:00
Reid Spencer
c44cb6bd9f
Expand the coercion of constants to include the newly constant Globals.
...
llvm-svn: 14966
2004-07-18 08:34:19 +00:00
Reid Spencer
539429d9b5
Delete a no-op loop.
...
llvm-svn: 14965
2004-07-18 08:32:43 +00:00
Reid Spencer
6c2b627e23
Expand the scope to include global values because they are now constants
...
too.
llvm-svn: 14964
2004-07-18 08:32:10 +00:00
Reid Spencer
cb3fb5d4f5
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
llvm-svn: 14953
2004-07-18 00:44:37 +00:00
Reid Spencer
874368790f
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
llvm-svn: 14950
2004-07-18 00:38:32 +00:00
Reid Spencer
ef784f01dd
bug 122:
...
- Minimize redundant isa<GlobalValue> usage
llvm-svn: 14948
2004-07-18 00:32:14 +00:00
Reid Spencer
c5afc9512b
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
- Correct isa<Constant> for GlobalValue subclass
llvm-svn: 14947
2004-07-18 00:31:05 +00:00
Reid Spencer
9e855c6832
bug 122:
...
- Minimize redundant isa<GlobalValue> usage
- Correct isa<Constant> for GlobalValue subclass
llvm-svn: 14946
2004-07-18 00:29:57 +00:00
Chris Lattner
d79334df33
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.
llvm-svn: 14861
2004-07-15 23:36:43 +00:00
Chris Lattner
f2c018c0c1
Fix PR404 try #2
...
This version takes about 1s longer than the previous one (down to 2.35s),
but on the positive side, it actually works :)
llvm-svn: 14856
2004-07-15 08:20:22 +00:00
Chris Lattner
daa12135da
Revert previous patch until I get a bug fixed
...
llvm-svn: 14853
2004-07-15 05:36:31 +00:00
Chris Lattner
70177e402d
Fix PR404: Loop simplify is really slow on 252.eon
...
This eliminates an N*N*logN algorithm from the loop simplify pass, replacing
it with a much simpler and faster alternative. In a debug build, this reduces
gccas time on eon from 85s to 42s.
llvm-svn: 14851
2004-07-15 04:27:04 +00:00
Chris Lattner
9a63520b1a
Fixes working towards PR341
...
llvm-svn: 14839
2004-07-15 01:50:47 +00:00
Chris Lattner
ba7aef39fd
Now that we codegen the portable "sizeof" efficiently, we can use it for
...
malloc lowering. This means that lowerallocations doesn't need targetdata
anymore. yaay.
llvm-svn: 14835
2004-07-15 01:08:08 +00:00
Chris Lattner
35e24774eb
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.
llvm-svn: 14783
2004-07-13 01:49:43 +00:00
Chris Lattner
9eb9ccd9f6
Check to make sure types are sized before calling getTypeSize on them.
...
llvm-svn: 14649
2004-07-06 19:28:42 +00:00
Brian Gaeke
a501be556f
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.
llvm-svn: 14648
2004-07-06 19:24:47 +00:00
Brian Gaeke
0e0fe8a2e9
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.)
llvm-svn: 14647
2004-07-06 18:15:39 +00:00
Chris Lattner
23b47b6af9
Implement rem.ll:test3
...
llvm-svn: 14640
2004-07-06 07:38:18 +00:00
Chris Lattner
98c6bdf251
Fix a minor bug where we would go into infinite loops on some constants
...
llvm-svn: 14638
2004-07-06 07:11:42 +00:00
Chris Lattner
7fd5f0745a
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.
llvm-svn: 14637
2004-07-06 07:01:22 +00:00
Reid Spencer
eb04d9bcb4
Add #include <iostream> since Value.h does not #include it any more.
...
llvm-svn: 14622
2004-07-04 12:19:56 +00:00
Chris Lattner
4c9c20af28
Implement add.ll:test22, a common case in MSIL files
...
llvm-svn: 14587
2004-07-03 00:26:11 +00:00
Chris Lattner
49df6cefa5
Do not call getTypeSize on a type that has no size
...
llvm-svn: 14584
2004-07-02 22:55:47 +00:00
Brian Gaeke
e1a136fb4b
Get rid of a dead variable, and fix a typo in a comment.
...
llvm-svn: 14560
2004-07-02 05:30:01 +00:00
Brian Gaeke
163c87fc32
Make this pass use a more specific debug message than "Processing:".
...
llvm-svn: 14541
2004-07-01 19:27:10 +00:00
Chris Lattner
6e07936ed2
Implement InstCombine/add.ll:test21
...
llvm-svn: 14443
2004-06-27 22:51:36 +00:00
Chris Lattner
7f4222237d
New constant expression lowering pass to simplify your instruction selection needs.
...
Contributed by Vladimir Prus!
llvm-svn: 14399
2004-06-25 07:48:09 +00:00
Chris Lattner
7a002d6010
Two fixes. First, stop using the ugly shouldSubstituteIndVar method.
...
Second, disable substitution of quadratic addrec expressions to avoid putting
multiplies in loops!
llvm-svn: 14358
2004-06-24 06:49:18 +00:00
Chris Lattner
c9e06336ab
Make use of BinaryOperator::create* methods to shrinkify code.
...
llvm-svn: 14262
2004-06-20 05:04:01 +00:00
Chris Lattner
42ad646104
Now that dominator tree children are built in determinstic order, this horrible code
...
can go away
llvm-svn: 14254
2004-06-19 20:23:35 +00:00
Chris Lattner
4027500e1c
Fix a nasty bug, noticed by Reid
...
llvm-svn: 14249
2004-06-19 18:15:50 +00:00
Chris Lattner
ec2d34cc19
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.
llvm-svn: 14248
2004-06-19 08:56:43 +00:00
Chris Lattner
b5f8eb8315
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.
llvm-svn: 14242
2004-06-19 02:02:22 +00:00
Chris Lattner
023a483c76
Implement Transforms/InstCombine/and.ll:test17, a common case that
...
occurs due to unordered comparison macros in math.h
llvm-svn: 14221
2004-06-18 06:07:51 +00:00
Chris Lattner
97bfcea262
Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
...
Delete two functions that are now methods on the Type class
llvm-svn: 14200
2004-06-17 18:16:02 +00:00
Brian Gaeke
661963c63f
Fix typo in DEBUG printout.
...
llvm-svn: 14196
2004-06-17 07:26:52 +00:00
Chris Lattner
ee59d4bf04
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. :)
llvm-svn: 14109
2004-06-10 02:33:20 +00:00
Chris Lattner
c8e7e298c1
More minor cleanups
...
llvm-svn: 14108
2004-06-10 02:12:35 +00:00
Chris Lattner
df20a4d589
Eliminate many occurrances of Instruction::
...
llvm-svn: 14107
2004-06-10 02:07:29 +00:00
Chris Lattner
35167c3087
Implement InstCombine/select.ll:test15*
...
llvm-svn: 14095
2004-06-09 07:59:58 +00:00
Chris Lattner
396dbfe327
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
llvm-svn: 14086
2004-06-09 05:08:07 +00:00
Chris Lattner
2dd017402b
Implement select.ll:test14*
...
llvm-svn: 14083
2004-06-09 04:24:29 +00:00
Chris Lattner
523d3e6674
Fix one of the major things that is causing the C Backend to infinite loop
...
llvm-svn: 13872
2004-05-28 05:02:13 +00:00
Chris Lattner
ed79d8af53
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!
llvm-svn: 13834
2004-05-27 17:30:27 +00:00
Reid Spencer
297d7fe7e6
Remove unused header file.
...
llvm-svn: 13750
2004-05-25 08:51:36 +00:00
Reid Spencer
1cc31f264f
Make this pass simply invoke SymbolTable::strip().
...
llvm-svn: 13749
2004-05-25 08:51:25 +00:00
Chris Lattner
e1e10e1883
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.
llvm-svn: 13740
2004-05-25 06:32:08 +00:00
Chris Lattner
03841659a4
Implement instcombine/cast.ll:test16:
...
Canonicalize cast X to bool into a setne instruction
llvm-svn: 13736
2004-05-25 04:29:21 +00:00
Chris Lattner
99173879ad
Spelling people's names right is kinda important
...
llvm-svn: 13702
2004-05-23 21:27:29 +00:00
Chris Lattner
289ba2ac4d
Adjust to the changes in the AliasSetTracker interface
...
llvm-svn: 13690
2004-05-23 21:20:19 +00:00
Chris Lattner
e67dbc2ae2
Add support for replacement of formal arguments with simpler expressions.
...
llvm-svn: 13689
2004-05-23 21:19:55 +00:00
Chris Lattner
099c8cfe90
Implement the -lowergc pass which is used by code generators (like the CBE)
...
that do not have builtin support for garbage collection.
llvm-svn: 13688
2004-05-23 21:19:22 +00:00
Chris Lattner
0026512bac
This was not meant to be committed
...
llvm-svn: 13565
2004-05-13 20:56:34 +00:00
Chris Lattner
c12c945cc4
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
llvm-svn: 13564
2004-05-13 20:43:31 +00:00
Chris Lattner
8ec5f88c79
Fix stupid bug in my checkin yesterday
...
llvm-svn: 13429
2004-05-08 22:41:42 +00:00
Chris Lattner
5f667a6f58
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.
llvm-svn: 13415
2004-05-07 22:09:22 +00:00
Chris Lattner
d9e5813821
Fix PR336: The instcombine pass asserts when visiting load instruction
...
llvm-svn: 13400
2004-05-07 15:35:56 +00:00
Chris Lattner
9490849028
Do not mark instructions in unreachable sections of the function as live.
...
This fixes PR332 and ADCE/2004-05-04-UnreachableBlock.llx
llvm-svn: 13349
2004-05-04 17:00:46 +00:00
Chris Lattner
dd1a86d858
Minor efficiency tweak, suggested by Patrick Meredith
...
llvm-svn: 13341
2004-05-04 15:19:33 +00:00
Chris Lattner
63d75af920
Make sure to reprocess instructions used by deleted instructions to avoid
...
missing opportunities for combination.
llvm-svn: 13309
2004-05-01 23:27:23 +00:00
Chris Lattner
b643a9e675
Make sure the instruction combiner doesn't lose track of instructions
...
when replacing them, missing the opportunity to do simplifications
llvm-svn: 13308
2004-05-01 23:19:52 +00:00
Chris Lattner
652064e3b8
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. :)
llvm-svn: 13289
2004-04-30 04:37:52 +00:00
Chris Lattner
2d3a7a6ff0
Changes to fix up the inst_iterator to pass to boost iterator checks. This
...
patch was graciously contributed by Vladimir Prus.
llvm-svn: 13185
2004-04-27 15:13:33 +00:00
Chris Lattner
e20c334e65
Instcombine X/-1 --> 0-X
...
llvm-svn: 13172
2004-04-26 14:01:59 +00:00
Chris Lattner
83cd87efcd
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.
llvm-svn: 13135
2004-04-23 21:29:48 +00:00
Chris Lattner
c27302c79f
Disable a previous patch that was causing indvars to loop infinitely :(
...
llvm-svn: 13108
2004-04-22 15:12:36 +00:00
Chris Lattner
c1a682dda0
Fix an extremely serious thinko I made in revision 1.60 of this file.
...
llvm-svn: 13106
2004-04-22 14:59:40 +00:00
Chris Lattner
af532f27e7
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. :)
llvm-svn: 13103
2004-04-21 23:36:08 +00:00
Chris Lattner
fb9a299f68
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. :)
llvm-svn: 13102
2004-04-21 22:29:37 +00:00
Chris Lattner
dc7cc35088
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.
llvm-svn: 13101
2004-04-21 22:22:01 +00:00
Chris Lattner
c1aa21f5a7
Fix PR325
...
llvm-svn: 13081
2004-04-20 20:26:03 +00:00
Chris Lattner
f48f777d4c
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.
llvm-svn: 13068
2004-04-19 18:07:02 +00:00
Chris Lattner
bc02177fdc
Add #include
...
llvm-svn: 13057
2004-04-19 03:01:23 +00:00
Chris Lattner
fc44a25bcb
Move isLoopInvariant to the Loop class
...
llvm-svn: 13051
2004-04-18 22:46:08 +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
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
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
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
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
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
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
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
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
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
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
6679e46b59
ADd a trivial instcombine: load null -> null
...
llvm-svn: 12940
2004-04-14 03:28:36 +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
d0dc6d5295
Constant propagation should remove the dead instructions
...
llvm-svn: 12917
2004-04-13 19:28:20 +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
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
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
Chris Lattner
494a685449
Add support for removing invoke instructions
...
llvm-svn: 12858
2004-04-12 05:15:13 +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
f16fe7206c
Update the value numbering interface.
...
llvm-svn: 12824
2004-04-10 22:33:34 +00:00
Chris Lattner
623fba1107
Implement InstCombine/select.ll:test13*
...
llvm-svn: 12821
2004-04-10 22:21:27 +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
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
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
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
56e4d3d8ad
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
llvm-svn: 12800
2004-04-09 23:46:01 +00:00
Chris Lattner
183b336a54
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
llvm-svn: 12794
2004-04-09 19:05:30 +00:00
Chris Lattner
cf7baf3519
Implement select.ll:test11
...
llvm-svn: 12793
2004-04-09 18:19:44 +00:00