Chris Lattner
bdcf41a8a2
Implement select.ll:test16: fold load (select C, X, null) -> load X
...
llvm-svn: 16499
2004-09-23 15:46:00 +00:00
Chris Lattner
b121ae1cec
Do not fold (X + C1 != C2) if there are other users of the add. Doing
...
this transformation used to take a loop like this:
int Array[1000];
void test(int X) {
int i;
for (i = 0; i < 1000; ++i)
Array[i] += X;
}
Compiled to LLVM is:
no_exit: ; preds = %entry, %no_exit
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=2]
%tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar ; <int*> [#uses=2]
%tmp.7 = load int* %tmp.4 ; <int> [#uses=1]
%tmp.9 = add int %tmp.7, %X ; <int> [#uses=1]
store int %tmp.9, int* %tmp.4
*** %indvar.next = add uint %indvar, 1 ; <uint> [#uses=2]
*** %exitcond = seteq uint %indvar.next, 1000 ; <bool> [#uses=1]
br bool %exitcond, label %return, label %no_exit
and turn it into a loop like this:
no_exit: ; preds = %entry, %no_exit
%indvar = phi uint [ 0, %entry ], [ %indvar.next, %no_exit ] ; <uint> [#uses=3]
%tmp.4 = getelementptr [1000 x int]* %Array, int 0, uint %indvar ; <int*> [#uses=2]
%tmp.7 = load int* %tmp.4 ; <int> [#uses=1]
%tmp.9 = add int %tmp.7, %X ; <int> [#uses=1]
store int %tmp.9, int* %tmp.4
*** %indvar.next = add uint %indvar, 1 ; <uint> [#uses=1]
*** %exitcond = seteq uint %indvar, 999 ; <bool> [#uses=1]
br bool %exitcond, label %return, label %no_exit
Note that indvar.next and indvar can no longer be coallesced. In machine
code terms, this patch changes this code:
.LBBtest_1: # no_exit
mov %EDX, OFFSET Array
mov %ESI, %EAX
add %ESI, DWORD PTR [%EDX + 4*%ECX]
mov %EDX, OFFSET Array
mov DWORD PTR [%EDX + 4*%ECX], %ESI
mov %EDX, %ECX
inc %EDX
cmp %ECX, 999
mov %ECX, %EDX
jne .LBBtest_1 # no_exit
into this:
.LBBtest_1: # no_exit
mov %EDX, OFFSET Array
mov %ESI, %EAX
add %ESI, DWORD PTR [%EDX + 4*%ECX]
mov %EDX, OFFSET Array
mov DWORD PTR [%EDX + 4*%ECX], %ESI
inc %ECX
cmp %ECX, 1000
jne .LBBtest_1 # no_exit
We need better instruction selection to get this:
.LBBtest_1: # no_exit
add DWORD PTR [Array + 4*%ECX], EAX
inc %ECX
cmp %ECX, 1000
jne .LBBtest_1 # no_exit
... but at least there is less register juggling
llvm-svn: 16473
2004-09-21 21:35:23 +00:00
Chris Lattner
42618551d5
Fix potential miscompilations: InstCombine/2004-09-20-BadLoadCombine*.llx
...
llvm-svn: 16447
2004-09-20 10:15:10 +00:00
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
4f2cf030e8
'Pass' should now not be derived from by clients. Instead, they should derive
...
from ModulePass. Instead of implementing Pass::run, then should implement
ModulePass::runOnModule.
llvm-svn: 16436
2004-09-20 04:48:05 +00:00
Chris Lattner
cd671065be
Prototype more accurately
...
llvm-svn: 16433
2004-09-20 04:43:57 +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
855a4ff4dd
Remove a whole bunch of horrible hacky code that was used to promote allocas
...
whose addresses where used by trivial phi nodes and select instructions. This
is now performed by the instcombine pass, which is more powerful, is much
simpler, and is faster. This allows the deletion of a bunch of code, two
FIXME's and two gotos.
llvm-svn: 16406
2004-09-19 18:51:51 +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
Chris Lattner
9864df96ba
Add comment
...
llvm-svn: 16400
2004-09-19 01:05:16 +00:00
Chris Lattner
6455c51ab6
Fix the inliner to always delete any edges from the external call node to
...
a function being deleted. Due to optimizations done while inlining, there
can be edges from the external call node to a function node that were not
apparent any longer.
This fixes the compiler crash while compiling 175.vpr
llvm-svn: 16399
2004-09-18 21:37:03 +00:00
Chris Lattner
37b6c4f2d2
Convert this pass to be a CallGraphSCCPass instead of a Pass, which eliminates
...
the worklist and makes it more efficient. This does not change functionality
at all.
llvm-svn: 16390
2004-09-18 00:34:13 +00:00
Chris Lattner
475dc2c93d
Make sure to remove the Select instruction as well
...
llvm-svn: 16389
2004-09-18 00:32:40 +00:00
Chris Lattner
5065b240c8
Fix typo in comment
...
llvm-svn: 16384
2004-09-17 03:58:39 +00:00
Chris Lattner
9face5eb1f
Add a newline
...
llvm-svn: 16369
2004-09-15 17:53:52 +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
9b9932bd94
If given an AliasSetTracker object to update, update it.
...
llvm-svn: 16347
2004-09-15 01:02:54 +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
14c198d09a
If we are linking two global variables and they have the same size, do not
...
spew warnings, even if the types don't match.
llvm-svn: 15933
2004-08-20 00:30:39 +00:00
Chris Lattner
6139134715
Implement test/Regression/Transforms/GlobalConstifier/phi-select.llx
...
This allows more globals to be marked constant, particularly global arrays.
llvm-svn: 15735
2004-08-14 20:57:17 +00:00
Chris Lattner
56273827b1
If we are extracting a block that has multiple successors that are the same
...
block (common in a switch), make sure to remove extra edges in successor
blocks. This fixes CodeExtractor/2004-08-12-BlockExtractPHI.ll and should
be pulled into LLVM 1.3 (though the regression test need not be, as that
would require pulling in the LoopExtract.cpp changes).
llvm-svn: 15717
2004-08-13 03:27:07 +00:00
Chris Lattner
f06b043204
When we code extract some stuff, leave the codeRepl block in the place where
...
the extracted code was, instead of putting it at the end of the function
llvm-svn: 15716
2004-08-13 03:17:39 +00:00
Chris Lattner
7386e6333d
"extract" the block extractor pass from bugpoint (haha)
...
llvm-svn: 15714
2004-08-13 03:05:17 +00:00
Chris Lattner
889d346e6e
Add value mapper support for select constant exprs. This should fix a bug
...
Nate ran into when bugpointing siod. This fix should go into LLVM 1.3
llvm-svn: 15712
2004-08-13 02:43:19 +00:00
Chris Lattner
cde351ee30
This patch makes the inliner refuse to inline functions that have alloca
...
instructions in the body of the function (not the entry block). This fixes
test/Programs/SingleSource/Regression/C/2004-08-12-InlinerAndAllocas.c
and test/Programs/External/SPEC/CINT2000/176.gcc on zion.
This should obviously be pulled into 1.3.
llvm-svn: 15684
2004-08-12 05:45:09 +00:00
Chris Lattner
7f1c7ede5b
Fix code extraction of unwind blocks. This fixed bugs that bugpoint can
...
run into. This should go into 1.3
llvm-svn: 15679
2004-08-12 03:17:02 +00:00
Chris Lattner
a7ba90e672
Hrm, this pass didn't compile. This bugfix should go into 1.3!
...
llvm-svn: 15676
2004-08-12 02:44:23 +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
Chris Lattner
4956a32c9e
Fix another really nasty regression that Anshu pointed out. In cases where
...
dangling constant users were removed from a function, causing it to be dead,
we never removed the call graph edge from the external node to the function.
In most cases, this didn't cause a problem (by luck). This should definitely
go into 1.3
llvm-svn: 15570
2004-08-08 03:29:50 +00:00
Chris Lattner
92b9906199
Two fixes:
...
1. Fix a REALLY nasty cyclic replacement issue that Anshu discovered, causing
nondeterminstic crashes and memory corruption.
2. For performance, don't go inserting constantexpr casts of GV pointers.
This should definitely go into 1.3
llvm-svn: 15568
2004-08-08 01:30:07 +00:00
Chris Lattner
6a93462144
This DEBUG is buggy. comment it out because it's not worth fixing. This
...
should go into 1.3
llvm-svn: 15567
2004-08-08 01:27:56 +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
Chris Lattner
7471b96a05
Expose this as a functionpass
...
llvm-svn: 15369
2004-07-31 10:01:58 +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
f4a410f907
Fix #includes of i*.h => Instructions.h as per PR403.
...
llvm-svn: 15337
2004-07-29 17:30:57 +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
Alkis Evlogimenos
fd7a2d4477
Merge i*.h headers into Instructions.h as part of bug403.
...
llvm-svn: 15325
2004-07-29 12:17:34 +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
Brian Gaeke
902dcf0729
These files don't need to include <iostream> since they include "Support/Debug.h".
...
llvm-svn: 15089
2004-07-21 20:50:33 +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
45b50d14c9
Fix a serious code pessimization problem. If an inlined function has a single
...
return, clone the 'ret' BB code into the block AFTER the inlined call, not the
other way around.
llvm-svn: 15030
2004-07-20 05:45:24 +00:00
Chris Lattner
11ffd59e37
Implement Transforms/InstCombine/IntPtrCast.ll
...
llvm-svn: 15029
2004-07-20 05:21:00 +00:00
Chris Lattner
ec67df0ed1
Ignore instructions that are in trivially dead functions. This allows us
...
to constify 14 globals instead of 4 in a trivial C++ testcase.
llvm-svn: 15027
2004-07-20 03:58:07 +00:00
Chris Lattner
44d0b9502a
Implement InstCombine/GEPIdxCanon.ll
...
llvm-svn: 15024
2004-07-20 01:48:15 +00:00
Chris Lattner
5823ac1c21
Implement SimplifyCFG/BrUnwind.ll
...
llvm-svn: 15022
2004-07-20 01:17:38 +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
e2774757fe
Fix a performance regression from the CPR patch, simplify code
...
llvm-svn: 14974
2004-07-18 21:34:16 +00:00
Chris Lattner
d47504d9db
Strip out and simplify some code. This also fixes the regression last
...
night compiling cfrac. It did not realize that code like this:
int G; int *H = &G;
takes the address of G.
llvm-svn: 14973
2004-07-18 19:56:20 +00:00
Chris Lattner
f3edc49ae2
Minor cleanup, no functionality change
...
llvm-svn: 14972
2004-07-18 18:59:44 +00:00
Reid Spencer
3b4e83ec83
Remove an if statement that would never be reached.
...
llvm-svn: 14968
2004-07-18 08:41:47 +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
199aeb7f59
Avoid an unnecessary isa<Constant>.
...
llvm-svn: 14963
2004-07-18 08:31:18 +00:00
Chris Lattner
9238d78dc3
Remove useless statistic, fix some slightly broken logic
...
llvm-svn: 14958
2004-07-18 07:22:58 +00:00
Chris Lattner
2da5eee33c
Fix a rather serious bug in previous checkin
...
llvm-svn: 14957
2004-07-18 06:56:58 +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
Reid Spencer
5f6815980b
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
- Rename methods to get ride of ConstantPointerRef usage
llvm-svn: 14945
2004-07-18 00:25:04 +00:00
Reid Spencer
83cae64faf
bug 122:
...
- Excise dead CPR procesing.
llvm-svn: 14944
2004-07-18 00:23:51 +00:00
Reid Spencer
e4de22874e
bug 122:
...
- Replace ConstantPointerRef usage with GlobalValue usage
- Correct test ordering for GlobalValue subclass
llvm-svn: 14943
2004-07-18 00:19:45 +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
32c518e526
Progress on PR341
...
llvm-svn: 14840
2004-07-15 02:06:12 +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
Vikram S. Adve
1097ed8467
Restoring this file.
...
llvm-svn: 14478
2004-06-29 14:20:27 +00:00
Chris Lattner
3b11d3b294
Remove unused file
...
llvm-svn: 14460
2004-06-28 00:46:58 +00:00
Chris Lattner
924882f775
These passes are long dead/obsolete. They never worked in the first place
...
and are a maintenence burden. Nuke nuke nuke
llvm-svn: 14457
2004-06-28 00:44:18 +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
Vikram S. Adve
463556f889
This file is unused, and duplicates functionality in TraceValues.cpp.
...
llvm-svn: 14369
2004-06-24 20:16:22 +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
Misha Brukman
49bb82a4b8
Moved to lib/VMCore
...
llvm-svn: 14348
2004-06-23 17:21:17 +00:00
Brian Gaeke
1ea8447089
Use new IsNAN() wrapper.
...
llvm-svn: 14340
2004-06-23 00:25:35 +00:00
Misha Brukman
ddc90adca3
File depends on DSA, moved to lib/Analysis/DataStructure
...
llvm-svn: 14325
2004-06-22 18:11:38 +00:00
Chris Lattner
f12c4a3d37
*FINALLY* Fix a really nasty nondeterministic bug that has been haunting us
...
since May 1st. In this code, the pred iterator was being invalidated sometimes
causing the wrong entries to be added to PHI nodes.
The fix for this is to defererence and safe the *PI value before we hack on
branch instructions, which changes use/def chains, which SOMETIMES invalidates
the iterator.
llvm-svn: 14278
2004-06-21 07:19:01 +00:00
Chris Lattner
46f60890a3
Comment out the isnan stuff until we get a proper autoconf test for it
...
breaking the build on sparc is not acceptable.
llvm-svn: 14277
2004-06-21 06:17:21 +00:00
Chris Lattner
1c676f76b6
Make order of argument addition deterministic. In particular, the layout
...
of ConstantInt objects in memory used to determine which order arguments
were added in in some cases.
llvm-svn: 14276
2004-06-21 00:07:58 +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
7d30a6c145
Fix the inliner to be deterministic, not letting its output depend on the
...
relative location of Function objects in memory.
llvm-svn: 14260
2004-06-20 04:11:48 +00:00
Chris Lattner
9734fd0980
Add some DEBUG output to the simplifycfg routines
...
Fix another non-deterministic behavior, this one should actually speed up the
code though as it was doing silly things.
llvm-svn: 14258
2004-06-20 01:13:18 +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
940b7ba5ad
This will hopefully fix a heisenbug that Vladimir Merzliakov is running
...
into valiantly trying to compile stuff on freebsd.
llvm-svn: 14251
2004-06-19 19:01:26 +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
4db0f8260a
Change to use the StableBasicBlockNumbering class
...
llvm-svn: 14247
2004-06-19 08:42:40 +00:00
Chris Lattner
a52ab6f57f
Do not let the numbering of PHI nodes placed in the function depend on
...
non-deterministic things like the ordering of blocks in the dominance
frontier of a BB. Unfortunately, I don't know of a better way to solve
this problem than to explicitly sort the BB's in function-order before
processing them. This is guaranteed to slow the pass down a bit, but
is absolutely necessary to get usable diffs between two different tools
executing the mem2reg or scalarrepl pass.
Before this, bazillions of spurious diff failures occurred all over the
place due to the different order of processing PHIs:
- %tmp.111 = getelementptr %struct.Connector_struct* %upcon.0.0, uint 0, uint 0
+ %tmp.111 = getelementptr %struct.Connector_struct* %upcon.0.1, uint 0, uint 0
Now, the diffs match.
llvm-svn: 14244
2004-06-19 07:40:14 +00:00
Chris Lattner
b2b151d297
Do not sort by the address of LLVM ConstantInt* objects. This produces
...
nondeterministic results that depend on where these objects land in memory.
Instead, sort by the value of the constant, which is stable.
Before this patch, the -simplifycfg pass run from two different compilers
could cause different code to be generated, though it was semantically the
same:
@@ -12258,8 +12258,8 @@
%s_addr.1 = phi sbyte* [ %s, %entry ], [ %inc.0, %no_exit ] ; <sbyte*> [#uses=5]
%tmp.1 = load sbyte* %s_addr.1 ; <sbyte> [#uses=1]
switch sbyte %tmp.1, label %no_exit [
- sbyte 0, label %loopexit
sbyte 46, label %loopexit
+ sbyte 0, label %loopexit
]
We need to stomp all of this stuff out.
llvm-svn: 14243
2004-06-19 07:02:14 +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
1e1abdd6ed
Do not function resolve intrinsics. This prevents warnings and possible bad
...
things from happening due to
declare bool %llvm.isunordered(double, double)
declare bool %llvm.isunordered(float, float)
llvm-svn: 14219
2004-06-18 05:50:48 +00:00
Brian Gaeke
27b13253d9
I love the smell of a freshly broken PowerPC build in the morning.
...
llvm-svn: 14206
2004-06-17 22:27:04 +00:00
Chris Lattner
f03f320b79
Fix compilation problem on freebsd. Problem noted by Vladimir Merzliakov in
...
PR371
llvm-svn: 14203
2004-06-17 21:20:52 +00:00
Chris Lattner
6b7275996c
Rename Type::PrimitiveID to TypeId and ::getPrimitiveID() to ::getTypeID()
...
llvm-svn: 14201
2004-06-17 18:19:28 +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
Brian Gaeke
20e09e5c7b
Um, did someone make a typo or something?
...
llvm-svn: 14192
2004-06-15 23:09:50 +00:00
Chris Lattner
5a542aadc8
Remove support for the isnan intrinsic
...
llvm-svn: 14186
2004-06-15 21:37:54 +00:00
Brian Gaeke
21370771ba
Quick hack to get this file compiling again on Mac OS X. The right thing to do
...
is write an autoconf macro that checks whether __isnan or isnan actually works
**using the C++ compiler after #include <cmath>**, instead of doing it the easy
way with AC_CHECK_FUNCS().
llvm-svn: 14171
2004-06-14 06:33:19 +00:00
Alkis Evlogimenos
e395468ae5
Add constant folding capabilities to the isunordered intrinsic.
...
llvm-svn: 14168
2004-06-13 01:23:56 +00:00
Chris Lattner
ec941f7abb
Constant fold the isnan intrinsic
...
llvm-svn: 14150
2004-06-11 06:16:23 +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
Brian Gaeke
a9c5779a86
Expand head-of-file comment.
...
llvm-svn: 13982
2004-06-03 05:03:02 +00:00
Brian Gaeke
c0b9b83450
Use new form of unconditional branch constructor.
...
llvm-svn: 13930
2004-06-01 20:06:10 +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
John Criswell
37d2ae92a7
Fix a bug in the -deadtypeelim pass. The SymbolTable re-write changed it
...
to eliminate the wrong type.
llvm-svn: 13855
2004-05-27 21:16:46 +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
Chris Lattner
c6e21fbd5c
Implement constant folding of fmod, which is used a lot in povray
...
llvm-svn: 13823
2004-05-27 07:25:00 +00:00
Chris Lattner
06158d140c
Restructure call constant folding code a bit to make it simpler
...
Add support for acos/asin/atan. 188.ammp contains three calls to acos with
constant arguments. Constant folding it allows elimination of those 3 calls
and three FP divisions of the results.
llvm-svn: 13821
2004-05-27 06:26:28 +00:00
Alkis Evlogimenos
0eefdcd73f
Do not pass a null pointer if this instruction is not prepended or
...
appended anywhere.
llvm-svn: 13798
2004-05-26 22:50:28 +00:00
Alkis Evlogimenos
9e84b503f0
Use one destination constructor for the unconditional branch.
...
llvm-svn: 13792
2004-05-26 21:38:14 +00:00
Reid Spencer
e7e9671cad
Convert to SymbolTable's new iteration interface.
...
llvm-svn: 13754
2004-05-25 08:53:40 +00:00
Reid Spencer
abb6f008ca
Convert to SymbolTable's new lookup and iteration interfaces.
...
llvm-svn: 13751
2004-05-25 08:52:20 +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
6f02714a10
Fix a bug in my previous checkin
...
llvm-svn: 13717
2004-05-24 06:24:46 +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
6754b827c6
Fix cases where we missed inlining some more obvious candidates because the
...
caller was in an SCC.
llvm-svn: 13693
2004-05-23 21:22:17 +00:00
Chris Lattner
8d7ff5e3dd
Simplify the interface and remove an unneeded #include
...
llvm-svn: 13692
2004-05-23 21:21:35 +00:00
Chris Lattner
254f8f8ad5
Fairly substantial changes to update the alias analysis we are querying as
...
we make the transformation. This allows us to use interprocedural alias
analyses successfully.
llvm-svn: 13691
2004-05-23 21:21:17 +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
Brian Gaeke
72185765bc
Add CloneTraceInto(), which is based on (and has mostly the same
...
effects as) CloneFunctionInto().
llvm-svn: 13601
2004-05-19 09:08:14 +00:00
Brian Gaeke
6182acf92a
Move RemapInstruction() to ValueMapper, so that it can be shared with
...
CloneTrace, and because it is primarily an operation on ValueMaps. It
is now a global (non-static) function which can be pulled in using
ValueMapper.h.
llvm-svn: 13600
2004-05-19 09:08:12 +00:00
Brian Gaeke
27e4943516
Clean up this pass somewhat:
...
Add better comments, including a better head-of-file comment.
Prune #includes.
Fix a FIXME that Chris put here by using doInitialization().
Use DEBUG() to print out debug msgs.
Give names to basic blocks inserted by this pass.
Expand tabs.
Use InsertProfilingInitCall() from ProfilingUtils to insert the initialize call.
llvm-svn: 13581
2004-05-14 21:21:52 +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
66219abac7
Do not pass in the same argument to the extracted function more than once, and
...
give the extracted function a more useful name than just foo_code.
llvm-svn: 13493
2004-05-12 16:26:18 +00:00
Chris Lattner
13d2ddfe9c
Implement support for code extracting basic blocks that have a return
...
instruction in them.
llvm-svn: 13490
2004-05-12 16:07:41 +00:00
Chris Lattner
795c9933e2
Implement splitting of PHI nodes, allowing block extraction of BB's that have
...
PHI node entries from multiple outside-the-region blocks. This also fixes
extraction of the entry block in a function. Yaay.
This has successfully block extracted all (but one) block from the score_move
function in obsequi (out of 33). Hrm, I wonder which block the bug is in. :)
llvm-svn: 13489
2004-05-12 15:29:13 +00:00
Chris Lattner
3b2917bfcf
* Pull some code out into the definedInRegion/definedInCaller methods
...
* Add a stub for the severSplitPHINodes which will allow us to bbextract
bb's with PHI nodes in them soon.
* Remove unused arguments from findInputsOutputs
* Dramatically simplify the code in findInputsOutputs. In particular,
nothing really cares whether or not a PHI node is using something.
* Move moveCodeToFunction to after emitCallAndSwitchStatement as that's the
order they get called.
* Fix a bug where we would code extract a region that included a call to
vastart. Like 'alloca', calls to vastart must stay in the function that
they are defined in.
* Add some comments.
llvm-svn: 13482
2004-05-12 06:01:40 +00:00
Chris Lattner
ffc4926263
Generate substantially better code when there are a limited number of exits
...
from the extracted region. If the return has 0 or 1 exit blocks, the new
function returns void. If it has 2 exits, it returns bool, otherwise it
returns a ushort as before.
This allows us to use a conditional branch instruction when there are two
exit blocks, as often happens during block extraction.
llvm-svn: 13481
2004-05-12 04:14:24 +00:00
Chris Lattner
3d1ca67fdd
Two minor improvements:
...
1. Get rid of the silly abort block. When doing bb extraction, we get one
abort block for every block extracted, which is kinda annoying.
2. If the switch ends up having a single destination, turn it into an
unconditional branch.
I would like to add support for conditional branches, but to do this we will
want to have the function return a bool instead of a ushort.
llvm-svn: 13478
2004-05-12 03:22:33 +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
Brian Gaeke
5237476f75
Fix typo
...
llvm-svn: 13340
2004-05-03 23:52:07 +00:00
Brian Gaeke
e96196081e
In InsertProfilingInitCall(), make it legal to pass in a null array, in
...
which case you'll get a null array and zero passed to the profiling function.
llvm-svn: 13336
2004-05-03 22:06:33 +00:00
Brian Gaeke
088dd3e121
Add initial implementation of basic-block tracing instrumentation pass.
...
llvm-svn: 13335
2004-05-03 22:06:32 +00:00
Chris Lattner
be6f06818c
Do not clone arbitrary condition instructions.
...
llvm-svn: 13316
2004-05-02 05:19:36 +00:00
Chris Lattner
51a6dbcb65
Do not infinitely "unroll" single BB loops.
...
llvm-svn: 13315
2004-05-02 05:02:03 +00:00
Chris Lattner
1e94ed606e
Dont' merge terminators that are needed to select PHI node values.
...
llvm-svn: 13312
2004-05-02 01:00:44 +00:00
Chris Lattner
2e93c4275e
Implement SimplifyCFG/branch-cond-merge.ll
...
Turning "if (A < B && B < C)" into "if (A < B & B < C)"
llvm-svn: 13311
2004-05-01 23:35:43 +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
4cbd160b45
Fix my missing parens
...
llvm-svn: 13307
2004-05-01 22:41:51 +00:00
Chris Lattner
88da6f7b52
Implement SimplifyCFG/branch-cond-prop.ll
...
llvm-svn: 13306
2004-05-01 22:36:37 +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
Misha Brukman
3596f0a180
* Allow aggregating extracted function arguments (controlled by flag)
...
* Commandline option (for now) controls that flag that is passed in
llvm-svn: 13141
2004-04-23 23:54:17 +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
Misha Brukman
98aa516a9c
Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
...
the function instead of isolating it. This also means the condition is reversed.
llvm-svn: 13112
2004-04-22 23:00:51 +00:00
Misha Brukman
e0682426f0
Add a flag to choose between isolating a function or deleting the function from
...
the Module. The default behavior keeps functionality as before: the chosen
function is the one that remains.
llvm-svn: 13111
2004-04-22 22:52:22 +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
be8bb804c5
Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :)
...
Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead
of a vector of pointers to them, but today is not that day.
llvm-svn: 13100
2004-04-21 20:44:33 +00:00
Alkis Evlogimenos
f68f40ea42
Include cerrno (gcc-3.4 fix)
...
llvm-svn: 13091
2004-04-21 16:11:40 +00:00
Chris Lattner
a9691fe70d
Fix typeo
...
llvm-svn: 13089
2004-04-21 14:23:18 +00:00
Chris Lattner
c87784f1fc
REALLY fix PR324: don't delete linkonce functions until after the SCC traversal
...
is done, which avoids invalidating iterators in the SCC traversal routines
llvm-svn: 13088
2004-04-20 22:06:53 +00:00
Chris Lattner
c1aa21f5a7
Fix PR325
...
llvm-svn: 13081
2004-04-20 20:26:03 +00:00
Chris Lattner
514934051a
Fix PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx
...
llvm-svn: 13080
2004-04-20 20:20:59 +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
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
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
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
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
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
ca52d0468e
Add a simple call constant propagation interface.
...
llvm-svn: 12919
2004-04-13 19:28:52 +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
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
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
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
0aa565647c
Fold code like:
...
if (C)
V1 |= V2;
into:
Vx = V1 | V2;
V1 = select C, V1, Vx
when the expression can be evaluated unconditionally and is *cheap* to
execute. This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:
int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;
void mux(void) {
output =
(in0 ? 0x00000001 : 0) | (in1 ? 0x00000002 : 0) |
(in2 ? 0x00000004 : 0) | (in3 ? 0x00000008 : 0) |
(in4 ? 0x00000010 : 0) | (in5 ? 0x00000020 : 0) |
(in6 ? 0x00000040 : 0) | (in7 ? 0x00000080 : 0) |
(in8 ? 0x00000100 : 0) | (in9 ? 0x00000200 : 0) |
(in10 ? 0x00000400 : 0) | (in11 ? 0x00000800 : 0) |
(in12 ? 0x00001000 : 0) | (in13 ? 0x00002000 : 0) |
(in14 ? 0x00004000 : 0) | (in15 ? 0x00008000 : 0) ;
}
llvm-svn: 12798
2004-04-09 22:50:22 +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
Chris Lattner
e228ee5870
Implement InstCombine/cast-propagate.ll
...
llvm-svn: 12784
2004-04-08 20:39:49 +00:00
Chris Lattner
3b3861d305
Implement ScalarRepl/select_promote.ll
...
llvm-svn: 12779
2004-04-08 19:59:34 +00:00
Chris Lattner
4d25c86b52
Remove the "really gross hacks" that are there to deal with recursive functions.
...
Now we collect all of the call sites we are interested in inlining, then inline
them. This entirely avoids issues with trying to inline a call site we got by
inlining another call site. This also eliminates iterator invalidation issues.
llvm-svn: 12770
2004-04-08 06:34:31 +00:00
Chris Lattner
1c631e813d
Implement InstCombine/select.ll:test[7-10]
...
llvm-svn: 12769
2004-04-08 04:43:23 +00:00
Chris Lattner
2b2412d0c8
Implement test/Regression/Transforms/InstCombine/getelementptr_index.ll
...
llvm-svn: 12762
2004-04-07 18:38:20 +00:00
Chris Lattner
4d1fcf1dcd
Fix a bug in yesterdays checkins which broke siod. siod is a great testcase! :)
...
llvm-svn: 12659
2004-04-05 16:02:41 +00:00
Chris Lattner
8953b90aaa
Fix InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll
...
llvm-svn: 12658
2004-04-05 02:10:19 +00:00
Chris Lattner
69193f93b6
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.
llvm-svn: 12653
2004-04-05 01:30:19 +00:00
Chris Lattner
e61b67d7d5
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.
llvm-svn: 12620
2004-04-02 20:24:31 +00:00
Chris Lattner
eed034bcd3
Fix the obvious bug in my previous checkin
...
llvm-svn: 12618
2004-04-02 18:15:10 +00:00
Chris Lattner
9f0db32625
Implement Transforms/SimplifyCFG/return-merge.ll
...
This actually causes us to turn code like:
return C ? A : B;
into a select instruction.
llvm-svn: 12617
2004-04-02 18:13:43 +00:00
Chris Lattner
c24019c825
Fix PR310 and TailDup/2004-04-01-DemoteRegToStack.llx
...
llvm-svn: 12597
2004-04-01 20:28:45 +00:00
Chris Lattner
59fdf74968
Remove some assertions that are now bogus with the last patch I put in
...
llvm-svn: 12595
2004-04-01 19:21:46 +00:00
Chris Lattner
146d0df5e4
Fix PR306: Loop simplify incorrectly updates dominator information
...
Testcase: LoopSimplify/2004-04-01-IncorrectDomUpdate.ll
llvm-svn: 12592
2004-04-01 19:06:07 +00:00
Chris Lattner
61fab1409d
Add warning
...
llvm-svn: 12573
2004-03-31 22:00:30 +00:00
Chris Lattner
709f03e2dd
Fix linking of constant expr casts due to type resolution changes. With
...
this and the other patches 253.perlbmk links again.
llvm-svn: 12565
2004-03-31 02:58:28 +00:00
Brian Gaeke
ef327be6ed
Start cleaning up this pass so that I can debug it.
...
llvm-svn: 12548
2004-03-30 19:53:46 +00:00
Chris Lattner
81bdcb90ce
Now that all the code generators support the select instruction, and the instcombine
...
pass can eliminate many nasty cases of them, start generating them in the optimizers
llvm-svn: 12545
2004-03-30 19:44:05 +00:00
Chris Lattner
533bc49775
Implement select.ll:test[3-6]
...
llvm-svn: 12544
2004-03-30 19:37:13 +00:00
Chris Lattner
059f390257
Add a simple select instruction lowering pass
...
llvm-svn: 12540
2004-03-30 18:41:10 +00:00
Chris Lattner
56b5051428
X % -1 == X % 1 == 0
...
llvm-svn: 12520
2004-03-26 16:11:24 +00:00
Chris Lattner
57c67b06e9
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
llvm-svn: 12519
2004-03-25 22:59:29 +00:00
Chris Lattner
abb77c9959
Teach the optimizer to delete zero sized alloca's (but not mallocs!)
...
llvm-svn: 12507
2004-03-19 06:08:10 +00:00
Chris Lattner
232155dc1b
Fix bug: CodeExtractor/2004-03-17-MissedLiveIns.ll
...
With this fix we now successfully extract all 149 loops from 256.bzip2 without
crashing or miscompiling the program!
llvm-svn: 12493
2004-03-18 05:56:32 +00:00
Chris Lattner
e83693560a
Add statistics to the loop extractor. The loop extractor has successfully
...
extracted all 63 loops for Olden/bh without crashing and without
miscompiling the program!!!
llvm-svn: 12491
2004-03-18 05:46:10 +00:00
Chris Lattner
5bce0c807d
Fix problem with PHI nodes having multiple predecessors from different
...
exit nodes
llvm-svn: 12490
2004-03-18 05:43:18 +00:00
Chris Lattner
acd75986ee
Fix CodeExtractor/2004-03-17-UpdatePHIsOutsideRegion.ll
...
llvm-svn: 12489
2004-03-18 05:38:31 +00:00
Chris Lattner
320d59f4cd
Seriously simplify and correct the PHI node handling code.
...
llvm-svn: 12487
2004-03-18 05:28:49 +00:00
Chris Lattner
d8017a340d
Fix CodeExtractor/2004-03-17-OutputMismatch.ll
...
llvm-svn: 12486
2004-03-18 04:12:05 +00:00
Chris Lattner
37de257ef0
Fix several bugs in the extractor:
...
1. Names were not put on the new arguments created (ok, this just helps sanity :)
2. Fix outgoing pointer values
3. Do not insert stores for values that had not been computed
4. Fix some wierd problems with the outset calculation
This fixes CodeExtractor/2004-03-14-DominanceProblem.ll, making the extractor
work on at least one simple case!
llvm-svn: 12484
2004-03-18 03:49:40 +00:00
Chris Lattner
e9235d2dde
The code extractor needs dominator info. Provide it
...
llvm-svn: 12483
2004-03-18 03:48:06 +00:00
Chris Lattner
cee3404d0a
Prune #includes, moving the module interface to the front. Note that this
...
exposed the fact that the header was not self-contained. There is a reason
we do things :)
llvm-svn: 12481
2004-03-18 03:15:29 +00:00
Chris Lattner
a078f47b39
Fix compilation of mesa, which I broke earlier today
...
llvm-svn: 12465
2004-03-17 02:02:47 +00:00
Chris Lattner
684fa5ac64
Be more accurate
...
llvm-svn: 12464
2004-03-17 01:59:27 +00:00
Chris Lattner
a3783a577e
Fix bug in previous checkin
...
llvm-svn: 12458
2004-03-16 23:36:49 +00:00
Chris Lattner
95057f6ad1
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
}
llvm-svn: 12457
2004-03-16 23:29:09 +00:00
Chris Lattner
bb1a2cc7ab
This code was both incredibly complex and incredibly broken. Fix it.
...
llvm-svn: 12456
2004-03-16 23:23:11 +00:00
Chris Lattner
fa48edfb7d
Punt if we see gigantic PHI nodes. This improves a huge interpreter loop
...
testcase from 32.5s in -raise to take .3s
llvm-svn: 12443
2004-03-16 19:52:53 +00:00
Chris Lattner
7a7b114871
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).
llvm-svn: 12442
2004-03-16 19:49:59 +00:00
Chris Lattner
a64923ad26
Do not copy gigantic switch instructions
...
llvm-svn: 12441
2004-03-16 19:45:22 +00:00
Chris Lattner
db5b8f4d6b
Fix a regression from this patch:
...
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040308/013095.html
Basically, this patch only updated the immediate dominatees of the header node
to tell them that the preheader also dominated them. In practice, ALL
dominatees of the header node are also dominated by the preheader.
This fixes: LoopSimplify/2004-03-15-IncorrectDomUpdate.
and PR293
llvm-svn: 12434
2004-03-16 06:00:15 +00:00
Chris Lattner
95ce36da0d
Restore old inlining heuristic. As the comment indicates, this is a nasty
...
horrible hack.
llvm-svn: 12423
2004-03-15 06:38:14 +00:00
Chris Lattner
cd83282df1
Add counters for the number of calls elimianted
...
llvm-svn: 12420
2004-03-15 05:46:59 +00:00
Chris Lattner
20cda2645e
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
llvm-svn: 12415
2004-03-15 04:11:30 +00:00
Chris Lattner
fb87cdecd8
Mostly cosmetic improvements. Do fix the bug where a global value was considered an input.
...
llvm-svn: 12406
2004-03-15 01:26:44 +00:00
Chris Lattner
73ab1fa7c8
Assert that input blocks meet the invariants we expect
...
Simplify the input/output finder. All elements of a basic block are
instructions. Any used arguments are also inputs. An instruction can only
be used by another instruction.
llvm-svn: 12405
2004-03-15 01:18:23 +00:00
Chris Lattner
2f155d8734
Fix several bugs in the loop extractor. In particular, subloops were never
...
extracted, and a function that contained a single top-level loop never had
the loop extracted, regardless of how much non-loop code there was.
llvm-svn: 12403
2004-03-15 00:02:02 +00:00
Chris Lattner
5b2072ecd3
No correctness fixes here, just minor qoi fixes:
...
* Don't insert a branch to the switch instruction after the call, just
make it a single block.
* Insert the new alloca instructions in the entry block of the original
function instead of having them execute dynamically
* Don't make the default edge of the switch instruction go back to the switch.
The loop extractor shouldn't create new loops!
* Give meaningful names to the alloca slots and the reload instructions
* Some minor code simplifications
llvm-svn: 12402
2004-03-14 23:43:24 +00:00
Chris Lattner
b4d8bf365c
Simplify code a bit, and fix bug CodeExtractor/2004-03-14-NoSwitchSupport.ll
...
This also implements a two minor improvements:
* Don't insert live-out stores IN the region, insert them on the code path
that exits the region
* If the region is exited to the same block from multiple paths, share the
switch statement entry, live-out store code, and the basic block.
llvm-svn: 12401
2004-03-14 23:05:49 +00:00
Chris Lattner
9c431f6c44
Simplify the code a bit by making the collection of basic blocks to extract
...
a member of the class. While we're at it, turn the collection into a set
instead of a vector to improve efficiency and make queries simpler.
llvm-svn: 12400
2004-03-14 22:34:55 +00:00
Chris Lattner
a1672c1bd8
Split into two passes. Now there is the general loop extractor, usable on
...
the command line, and the single loop extractor, usable by bugpoint
llvm-svn: 12390
2004-03-14 20:01:36 +00:00
Chris Lattner
0137de5ecb
Passes don't print stuff!
...
llvm-svn: 12385
2004-03-14 04:17:53 +00:00
Chris Lattner
b68659552a
Do not create empty basic blocks when the lowerswitch pass expects blocks to
...
be non-empty! This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll
llvm-svn: 12384
2004-03-14 04:14:31 +00:00
Chris Lattner
4fca71eb44
Minor random cleanups
...
llvm-svn: 12382
2004-03-14 04:01:47 +00:00
Chris Lattner
6c3e8c78cf
FunctionPass's should not define their own 'run' method.
...
Require 'simplified' loops, not just raw natural loops. This fixes
CodeExtractor/2004-03-13-LoopExtractorCrash.ll
llvm-svn: 12381
2004-03-14 04:01:06 +00:00
Chris Lattner
d078812f96
If a block is dead, dominators will not be calculated for it. Because of this
...
loop information won't see it, and we could have unreachable blocks pointing to
the non-header node of blocks in a natural loop. This isn't tidy, so have the
loopsimplify pass clean it up.
llvm-svn: 12380
2004-03-14 03:59:22 +00:00
Chris Lattner
3684469326
Verify functions as they are produced if -debug is specified. Reduce
...
curly braceage
llvm-svn: 12378
2004-03-14 03:17:22 +00:00
Chris Lattner
78a996aec4
Move prototype to IPO.h instead of Scalar.h
...
Make sure that the file interface header (IPO.h) is included first
remove dead #incldue
llvm-svn: 12375
2004-03-14 02:37:16 +00:00
Chris Lattner
692a47aeb9
Indent anon namespace properly, add copyright block
...
llvm-svn: 12373
2004-03-14 02:34:07 +00:00
Chris Lattner
41ec709e00
Move to the IPO library. Utils shouldn't contain passes.
...
llvm-svn: 12372
2004-03-14 02:32:27 +00:00
Chris Lattner
8eebc49884
DemoteRegToStack got moved from DemoteRegToStack.h to Local.h
...
llvm-svn: 12368
2004-03-14 02:13:38 +00:00
Chris Lattner
7d2a539735
Add some debugging output
...
Fix InstCombine/2004-03-13-InstCombineInfLoop.ll which caused an infinite
loop compiling (I think) povray.
llvm-svn: 12365
2004-03-13 23:54:27 +00:00
Chris Lattner
2dc85b27e4
This change makes two big adjustments.
...
* Be a lot more accurate about what the effects will be when inlining a call
to a function when an argument is an alloca.
* Dramatically reduce the penalty for inlining a call in a large function.
This heuristic made it almost impossible to inline a function into a large
function, no matter how small the callee is.
llvm-svn: 12363
2004-03-13 23:15:45 +00:00
Chris Lattner
797cb2f6c1
This little patch speeds up the loop used to update the dominator set analysis.
...
On the testcase from GCC PR12440, which has a LOT of loops (1392 of which require
preheaders to be inserted), this speeds up the loopsimplify pass from 1.931s to
0.1875s. The loop in question goes from 1.65s -> 0.0097s, which isn't bad. All of
these times are a debug build.
This adds a dependency on DominatorTree analysis that was not there before, but
we always had dominatortree available anyway, because LICM requires both loop
simplify and DT, so this doesn't add any extra analysis in practice.
llvm-svn: 12362
2004-03-13 22:01:26 +00:00
Chris Lattner
022167f13b
Implement sub.ll:test14
...
llvm-svn: 12355
2004-03-13 00:11:49 +00:00
Chris Lattner
92295c5031
Implement InstCombine/sub.ll:test12 & test13
...
llvm-svn: 12353
2004-03-12 23:53:13 +00:00
Chris Lattner
cb015ee6c0
Add constant folding wrapper support for select instructions.
...
llvm-svn: 12319
2004-03-12 05:53:03 +00:00
Chris Lattner
59db22dcd4
Add sccp support for select instructions
...
llvm-svn: 12318
2004-03-12 05:52:44 +00:00
Chris Lattner
b909e8b0d4
Add trivial optimizations for select instructions
...
llvm-svn: 12317
2004-03-12 05:52:32 +00:00
Chris Lattner
721264aecc
Initial support for edge profiling
...
llvm-svn: 12225
2004-03-08 17:54:34 +00:00
Chris Lattner
dae48f93b0
Split utility functions out of BlockProfiling.cpp
...
llvm-svn: 12224
2004-03-08 17:06:13 +00:00
Chris Lattner
d91e676700
finegrainify namespacification
...
llvm-svn: 12221
2004-03-08 16:45:53 +00:00
Chris Lattner
fe6f2e3e80
Implement ArgumentPromotion/aggregate-promote.ll
...
This allows pointers to aggregate objects, whose elements are only read, to
be promoted and passed in by element instead of by reference. This can
enable a LOT of subsequent optimizations in the caller function.
It's worth pointing out that this stuff happens a LOT of C++ programs, because
objects in templates are generally passed around by reference. When these
templates are instantiated on small aggregate or scalar types, however, it is
more efficient to pass them in by value than by reference.
This transformation triggers most on C++ codes (e.g. 334 times on eon), but
does happen on C codes as well. For example, on mesa it triggers 72 times,
and on gcc it triggers 35 times. this is amazingly good considering that
we are using 'basicaa' so far.
llvm-svn: 12202
2004-03-08 01:04:36 +00:00
Chris Lattner
cc544e57f3
Implement: ArgumentPromotion/chained.ll
...
llvm-svn: 12200
2004-03-07 22:52:53 +00:00
Chris Lattner
64b8d697ad
Fix another minor bug, exposed by perlbmk
...
llvm-svn: 12198
2004-03-07 22:43:27 +00:00
Chris Lattner
538fee7aa2
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.
llvm-svn: 12197
2004-03-07 22:16:24 +00:00
Chris Lattner
6770842b67
Fix a minor bug and turn debug output into, well, debug output.
...
llvm-svn: 12195
2004-03-07 21:54:50 +00:00
Chris Lattner
483ae01c9c
New LLVM pass: argument promotion. This version only handles simple scalar
...
variables.
llvm-svn: 12193
2004-03-07 21:29:54 +00:00
Chris Lattner
7abcc387de
Don't emit things like malloc(16*1). Allocation instructions are fixed arity now.
...
llvm-svn: 12086
2004-03-03 01:40:53 +00:00
Misha Brukman
f44acae31e
Implement ExtractCodeRegion()
...
llvm-svn: 12070
2004-03-02 00:20:57 +00:00
Misha Brukman
f272f9b3d5
Make a note that this is usually used via bugpoint.
...
llvm-svn: 12068
2004-03-02 00:19:09 +00:00
Misha Brukman
5af2be7d09
* Add implementation of ExtractBasicBlock()
...
* Add comments to ExtractLoop()
llvm-svn: 12053
2004-03-01 18:28:34 +00:00
Chris Lattner
5cf39339d1
Disable tail duplication in a case that breaks on Olden/tsp
...
llvm-svn: 12021
2004-03-01 01:12:13 +00:00
Misha Brukman
c91e1ff50d
* Remove function to find "main" in a Module, there's a method for that
...
* Removing extraneous empty space and empty comment lines
llvm-svn: 12014
2004-02-29 23:09:10 +00:00
Chris Lattner
2de229f31b
Fix bug: test/Regression/Transforms/LowerInvoke/2004-02-29-PHICrash.llx
...
... which tickled the lowerinvoke pass because it used the BCE routines.
llvm-svn: 12012
2004-02-29 22:24:41 +00:00
Chris Lattner
bf2963ef91
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.
llvm-svn: 11989
2004-02-29 06:41:20 +00:00
Chris Lattner
d3e6ae263c
Implement switch->br and br->switch folding by ripping out the switch->switch
...
and br->br code and generalizing it. This allows us to compile code like this:
int test(Instruction *I) {
if (isa<CastInst>(I))
return foo(7);
else if (isa<BranchInst>(I))
return foo(123);
else if (isa<UnwindInst>(I))
return foo(1241);
else if (isa<SetCondInst>(I))
return foo(1);
else if (isa<VAArgInst>(I))
return foo(42);
return foo(-1);
}
into:
int %_Z4testPN4llvm11InstructionE("struct.llvm::Instruction"* %I) {
entry:
%tmp.1.i.i.i.i.i.i.i = getelementptr "struct.llvm::Instruction"* %I, long 0, ubyte 4 ; <uint*> [#uses=1]
%tmp.2.i.i.i.i.i.i.i = load uint* %tmp.1.i.i.i.i.i.i.i ; <uint> [#uses=2]
%tmp.2.i.i.i.i.i.i = seteq uint %tmp.2.i.i.i.i.i.i.i, 27 ; <bool> [#uses=0]
switch uint %tmp.2.i.i.i.i.i.i.i, label %endif.0 [
uint 27, label %then.0
uint 2, label %then.1
uint 5, label %then.2
uint 14, label %then.3
uint 15, label %then.3
uint 16, label %then.3
uint 17, label %then.3
uint 18, label %then.3
uint 19, label %then.3
uint 32, label %then.4
]
...
As well as handling the cases in 176.gcc and many other programs more effectively.
llvm-svn: 11964
2004-02-28 21:28:10 +00:00
Chris Lattner
772eafa332
if there is already a prototype for malloc/free, use it, even if it's incorrect.
...
Do not just inject a new prototype.
llvm-svn: 11951
2004-02-28 18:51:45 +00:00
Chris Lattner
51ea127bf3
Rename AddUsesToWorkList -> AddUsersToWorkList, as that is what it does.
...
Create a new AddUsesToWorkList method
optimize memmove/set/cpy of zero bytes to a noop.
llvm-svn: 11941
2004-02-28 05:22:00 +00:00
Chris Lattner
f3a366062c
Turn 'free null' into nothing
...
llvm-svn: 11940
2004-02-28 04:57:37 +00:00
Misha Brukman
8a2c28fdda
Right, it's really Extractor, not Extraction.
...
llvm-svn: 11939
2004-02-28 03:37:58 +00:00
Misha Brukman
03a11340ff
A pass that uses the generic CodeExtractor to rip out *every* loop in every
...
function, as long as the loop isn't the only one in that function. This should
help debugging passes easier with BugPoint.
llvm-svn: 11936
2004-02-28 03:33:01 +00:00
Misha Brukman
caa1a5abeb
A generic code extractor: given a list of BasicBlocks, it will rip them out into
...
a new function, taking care of inputs and outputs.
llvm-svn: 11935
2004-02-28 03:26:20 +00:00
Chris Lattner
e82c217b2f
setcond instructions don't have aliasing implications.
...
llvm-svn: 11919
2004-02-27 18:09:25 +00:00
Chris Lattner
4f7accab96
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.
llvm-svn: 11900
2004-02-27 06:27:46 +00:00
Chris Lattner
79636d7cd5
Since LLVM uses structure type equivalence, it isn't useful to keep around
...
multiple type names for the same structural type. Make DTE eliminate all
but one of the type names
llvm-svn: 11879
2004-02-26 20:02:23 +00:00
Chris Lattner
21e941fbfd
turn things like:
...
if (X == 0 || X == 2)
...where the comparisons and branches are in different blocks... into a switch
instruction. This comes up a lot in various programs, and works well with
the switch/switch merging code I checked earlier. For example, this testcase:
int switchtest(int C) {
return C == 0 ? f(123) :
C == 1 ? f(3123) :
C == 4 ? f(312) :
C == 5 ? f(1234): f(444);
}
is converted into this:
switch int %C, label %cond_false.3 [
int 0, label %cond_true.0
int 1, label %cond_true.1
int 4, label %cond_true.2
int 5, label %cond_true.3
]
instead of a whole bunch of conditional branches.
Admittedly the code is ugly, and incomplete. To be complete, we need to add
br -> switch merging and switch -> br merging. For example, this testcase:
struct foo { int Q, R, Z; };
#define A (X->Q+X->R * 123)
int test(struct foo *X) {
return A == 123 ? X1() :
A == 12321 ? X2():
(A == 111 || A == 222) ? X3() :
A == 875 ? X4() : X5();
}
Gets compiled to this:
switch int %tmp.7, label %cond_false.2 [
int 123, label %cond_true.0
int 12321, label %cond_true.1
int 111, label %cond_true.2
int 222, label %cond_true.2
]
...
cond_false.2: ; preds = %entry
%tmp.52 = seteq int %tmp.7, 875 ; <bool> [#uses=1]
br bool %tmp.52, label %cond_true.3, label %cond_false.3
where the branch could be folded into the switch.
This kind of thing occurs *ALL OF THE TIME*, especially in programs like
176.gcc, which is a horrible mess of code. It contains stuff like *shudder*:
#define SWITCH_TAKES_ARG(CHAR) \
( (CHAR) == 'D' \
|| (CHAR) == 'U' \
|| (CHAR) == 'o' \
|| (CHAR) == 'e' \
|| (CHAR) == 'u' \
|| (CHAR) == 'I' \
|| (CHAR) == 'm' \
|| (CHAR) == 'L' \
|| (CHAR) == 'A' \
|| (CHAR) == 'h' \
|| (CHAR) == 'z')
and
#define CONST_OK_FOR_LETTER_P(VALUE, C) \
((C) == 'I' ? SMALL_INTVAL (VALUE) \
: (C) == 'J' ? SMALL_INTVAL (-(VALUE)) \
: (C) == 'K' ? (unsigned)(VALUE) < 32 \
: (C) == 'L' ? ((VALUE) & 0xffff) == 0 \
: (C) == 'M' ? integer_ok_for_set (VALUE) \
: (C) == 'N' ? (VALUE) < 0 \
: (C) == 'O' ? (VALUE) == 0 \
: (C) == 'P' ? (VALUE) >= 0 \
: 0)
and
#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
{ \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
copy_to_mode_reg (SImode, XEXP (X, 1))); \
if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
copy_to_mode_reg (SImode, XEXP (X, 0))); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 1), \
force_operand (XEXP (X, 0), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
(X) = gen_rtx (PLUS, SImode, XEXP (X, 0), \
force_operand (XEXP (X, 1), 0)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
XEXP (X, 1)); \
if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
(X) = gen_rtx (PLUS, Pmode, XEXP (X, 0), \
force_operand (XEXP (X, 1), NULL_RTX)); \
if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
|| GET_CODE (X) == LABEL_REF) \
(X) = legitimize_address (flag_pic, X, 0, 0); \
if (memory_address_p (MODE, X)) \
goto WIN; }
and others. These macros get used multiple times of course. These are such
lovely candidates for macros, aren't they? :)
This code also nicely handles LLVM constructs that look like this:
if (isa<CastInst>(I))
...
else if (isa<BranchInst>(I))
...
else if (isa<SetCondInst>(I))
...
else if (isa<UnwindInst>(I))
...
else if (isa<VAArgInst>(I))
...
where the isa can obviously be a dyn_cast as well. Switch instructions are a
good thing.
llvm-svn: 11870
2004-02-26 07:13:46 +00:00
Chris Lattner
8d1da1abee
My faith in programmers has been found to be totally misplaced. One would
...
assume that if they don't intend to write to a global variable, that they
would mark it as constant. However, there are people that don't understand
that the compiler can do nice things for them if they give it the information
it needs.
This pass looks for blatently obvious globals that are only ever read from.
Though it uses a trivially simple "alias analysis" of sorts, it is still able
to do amazing things to important benchmarks. 253.perlbmk, for example,
contains several ***GIANT*** function pointer tables that are not marked
constant and should be. Marking them constant allows the optimizer to turn
a whole bunch of indirect calls into direct calls. Note that only a link-time
optimizer can do this transformation, but perlbmk does have several strings
and other minor globals that can be marked constant by this pass when run
from GCCAS.
176.gcc has a ton of strings and large tables that are marked constant, both
at compile time (38 of them) and at link time (48 more). Other benchmarks
give similar results, though it seems like big ones have disproportionally
more than small ones.
This pass is extremely quick and does good things. I'm going to enable it
in gccas & gccld. Not bad for 50 SLOC.
llvm-svn: 11836
2004-02-25 21:34:36 +00:00
Chris Lattner
9c6833c5ca
Fix incorrect debug code
...
llvm-svn: 11821
2004-02-25 15:15:04 +00:00
Chris Lattner
8ee0593f0d
Fix a faulty optimization on FP values
...
llvm-svn: 11801
2004-02-24 18:10:14 +00:00
Chris Lattner
90ea78edba
If a block is made dead, make sure to promptly remove it.
...
llvm-svn: 11799
2004-02-24 16:09:21 +00:00
Chris Lattner
a2ab489135
Implement SimplifyCFG/switch_switch_fold.ll
...
This case occurs many times in various benchmarks, especially when combined
with the previous patch. This allows it to get stuff like:
if (X == 4 || X == 3)
if (X == 5 || X == 8)
and
switch (X) {
case 4: case 5: case 6:
if (X == 4 || X == 5)
llvm-svn: 11797
2004-02-24 07:23:58 +00:00
Chris Lattner
3cd98f054a
Rearrange code a bit
...
llvm-svn: 11793
2004-02-24 05:54:22 +00:00
Chris Lattner
6f4b45acf5
Implement: test/Regression/Transforms/SimplifyCFG/switch_create.ll
...
This turns code like this:
if (X == 4 | X == 7)
and
if (X != 4 & X != 7)
into switch instructions.
llvm-svn: 11792
2004-02-24 05:38:11 +00:00
Chris Lattner
ae739aefd7
Generate much more efficient code in programs like pifft
...
llvm-svn: 11775
2004-02-23 21:46:58 +00:00
Chris Lattner
c40b9d7d51
Fix a small typeo in my checkin last night that broke vortex and other programs :(
...
llvm-svn: 11774
2004-02-23 21:46:42 +00:00
Chris Lattner
f5ce254692
Fix InstCombine/2004-02-23-ShiftShiftOverflow.ll
...
Also, turn 'shr int %X, 1234' into 'shr int %X, 31'
llvm-svn: 11768
2004-02-23 20:30:06 +00:00
Chris Lattner
2b55ea38bc
Implement cast.ll::test14/15
...
llvm-svn: 11742
2004-02-23 07:16:20 +00:00
Chris Lattner
e79e854c5c
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.
llvm-svn: 11740
2004-02-23 06:38:22 +00:00
Chris Lattner
c8a10c4b6a
Implement mul.ll:test11
...
llvm-svn: 11737
2004-02-23 06:00:11 +00:00
Chris Lattner
59611149ee
Implement "strength reduction" of X <= C and X >= C
...
llvm-svn: 11735
2004-02-23 05:47:48 +00:00
Chris Lattner
2635b52d4e
Implement InstCombine/mul.ll:test10, which is a case that occurs when dealing
...
with "predication"
llvm-svn: 11734
2004-02-23 05:39:21 +00:00
Chris Lattner
8d0bacbb9e
Implement Transforms/InstCombine/cast.ll:test13, a case which occurs in a
...
hot 164.gzip loop.
llvm-svn: 11702
2004-02-22 05:25:17 +00:00
Chris Lattner
693e393fee
Fix PR245: Linking weak and strong global variables is dependent on link order
...
llvm-svn: 11565
2004-02-17 21:56:04 +00:00
Chris Lattner
e42732e75f
Implement test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll,
...
see the testcase for the reasoning.
llvm-svn: 11496
2004-02-16 06:35:48 +00:00
Chris Lattner
4db2d22bea
Fold PHI nodes of constants which are only used by a single cast. This implements
...
phi.ll:test4
llvm-svn: 11494
2004-02-16 05:07:08 +00:00
Chris Lattner
b36d908f7b
Teach LLVM to unravel the "swap idiom". This implements:
...
Regression/Transforms/InstCombine/xor.ll:test20
llvm-svn: 11492
2004-02-16 03:54:20 +00:00
Chris Lattner
c207635fd5
Implement Transforms/InstCombine/xor.ll:test19
...
llvm-svn: 11490
2004-02-16 01:20:27 +00:00
Chris Lattner
d85e061575
Instead of producing calls to setjmp/longjmp, produce uses of the
...
llvm.setjmp/llvm.longjmp intrinsics.
llvm-svn: 11482
2004-02-15 22:24:27 +00:00
Chris Lattner
76b2ff4ded
Adjustments to support the new ConstantAggregateZero class
...
llvm-svn: 11474
2004-02-15 05:55:15 +00:00
Chris Lattner
37a716fa80
Remove dependence on return type of ConstantStruct::get
...
llvm-svn: 11466
2004-02-15 04:07:32 +00:00
Chris Lattner
c75bf528c1
Remove dependence on the return type of ConstantArray::get
...
llvm-svn: 11463
2004-02-15 04:05:58 +00:00
Chris Lattner
283ffdfac5
Fix compilation of 126.gcc: intrinsic functions cannot throw, so they are not
...
allowed in invoke instructions. Thus, if we are inlining a call to an intrinsic
function into an invoke site, we don't need to turn the call into an invoke!
llvm-svn: 11384
2004-02-13 16:47:35 +00:00
Chris Lattner
7db49ce5b4
Intrinsic functions cannot throw
...
llvm-svn: 11383
2004-02-13 16:46:46 +00:00
Chris Lattner
7cbb22abe6
Expose a pass ID that can be 'required'
...
llvm-svn: 11376
2004-02-13 16:16:16 +00:00
Chris Lattner
d4b36cf9bc
Remove obsolete comment. Unreachable blocks will automatically be left at the
...
end of the function.
llvm-svn: 11313
2004-02-11 05:20:50 +00:00
Chris Lattner
5add05129e
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.
llvm-svn: 11311
2004-02-11 04:53:20 +00:00
Chris Lattner
18d1f19fba
Implement SimplifyCFG/PhiEliminate.ll
...
Having a proper 'select' instruction would allow the elimination of a lot
of the special case cruft in this patch, but we don't have one yet.
llvm-svn: 11307
2004-02-11 03:36:04 +00:00
Chris Lattner
838b845781
The hasConstantReferences predicate always returns false.
...
llvm-svn: 11301
2004-02-11 01:17:07 +00:00
Chris Lattner
3232bbb9d8
initialization calls now return argc. If the program uses the argc value
...
passed into main, make sure they use the return value of the init call
instead of the one passed in.
llvm-svn: 11262
2004-02-10 17:41:01 +00:00
Chris Lattner
37d46f4815
Only add the global variable with the abort message if an unwind actually
...
occurs in the program.
llvm-svn: 11249
2004-02-09 22:48:47 +00:00
Chris Lattner
e3af6f73ce
Don't depend on auto data conversion
...
llvm-svn: 11229
2004-02-09 05:16:30 +00:00
Chris Lattner
ac6db755c3
Adjust to the changed StructType interface. In particular, getElementTypes() is gone.
...
llvm-svn: 11228
2004-02-09 04:37:31 +00:00
Chris Lattner
fa829be4d3
Start using the new and improve interface to FunctionType arguments
...
llvm-svn: 11224
2004-02-09 04:14:01 +00:00
Chris Lattner
57ea2e3294
The ConstantExpr::getCast call can cause a CPR to be generated. If so,
...
strip it off.
llvm-svn: 11213
2004-02-09 00:20:55 +00:00
Misha Brukman
3480e935d0
Fix grammar-o.
...
llvm-svn: 11210
2004-02-08 22:27:33 +00:00
Chris Lattner
3b7f6b2217
Improve compatibility with programs that already have a prototype for 'write',
...
even if it is wierd in some way.
llvm-svn: 11207
2004-02-08 22:14:44 +00:00
Chris Lattner
fae8ab3088
rename the "exceptional" destination of an invoke instruction to the 'unwind' dest
...
llvm-svn: 11202
2004-02-08 21:44:31 +00:00
Chris Lattner
56997dd283
Fix PR225: [pruneeh] -pruneeh pass removes invoke instructions it shouldn't
...
llvm-svn: 11200
2004-02-08 21:15:59 +00:00
Chris Lattner
071bc60450
splitBasicBlock "does the right thing" now, no reason to reposition it.
...
llvm-svn: 11199
2004-02-08 20:49:07 +00:00
Chris Lattner
108cadc274
Implement proper invoke/unwind lowering.
...
This fixed PR16 "[lowerinvoke] The -lowerinvoke pass does not insert calls to setjmp/longjmp"
llvm-svn: 11195
2004-02-08 19:53:56 +00:00
Chris Lattner
476488e669
Add a call to 'write' right before the call to abort() in the unwind path.
...
This causes the JIT, or LLC'd program to print out a nice message, explaining
WHY the program aborted.
llvm-svn: 11184
2004-02-08 07:30:29 +00:00
Chris Lattner
2dd1c8d8ce
Fix another dominator update bug. These bugs keep getting exposed because GCSE
...
keeps finding more code motion opportunities now that the dominators are correct!
llvm-svn: 11142
2004-02-05 23:20:59 +00:00
Chris Lattner
c0c953f0bc
Fix bug updating dominators
...
llvm-svn: 11140
2004-02-05 22:33:26 +00:00
Chris Lattner
f978c421e5
Add debug output
...
llvm-svn: 11139
2004-02-05 22:33:19 +00:00
Chris Lattner
14ab84a483
Fix PR223: Loopsimplify incorrectly updates dominator information
...
The problem is that the dominator update code didn't "realize" that it's
possible for the newly inserted basic block to dominate anything. Because
it IS possible, stuff was getting updated wrong.
llvm-svn: 11137
2004-02-05 21:12:24 +00:00
Chris Lattner
39ad6f2772
Minor speedup, don't query ValueMap each time through the loop
...
llvm-svn: 11123
2004-02-04 21:44:26 +00:00
Chris Lattner
6f8865bf9f
Two changes:
...
1. Don't scan to the end of alloca instructions in the caller function to
insert inlined allocas, just insert at the top. This saves a lot of
time inlining into functions with a lot of allocas.
2. Use splice to move the alloca instructions over, instead of remove/insert.
This allows us to transfer a block at a time, and eliminates a bunch of
silly symbol table manipulations.
This speeds up the inliner on the testcase in PR209 from 1.73s -> 1.04s (67%)
llvm-svn: 11118
2004-02-04 21:33:42 +00:00
Chris Lattner
0fa8c7c321
Optimize the case where we are inlining a function that contains only one basic block,
...
and that basic block ends with a return instruction. In this case, we can just splice
the cloned "body" of the function directly into the source basic block, avoiding a lot
of rearrangement and splitBasicBlock's linear scan over the split block. This speeds up
the inliner on the testcase in PR209 from 2.3s to 1.7s, a 35% reduction.
llvm-svn: 11116
2004-02-04 04:17:06 +00:00
Chris Lattner
8d414ad035
Adjust to the new BasicBlock ctor, which requires a function parameter
...
llvm-svn: 11114
2004-02-04 03:58:28 +00:00
Chris Lattner
0ff9da5fed
Remove unneeded code now that splitBasicBlock does the "right thing"
...
llvm-svn: 11111
2004-02-04 03:21:51 +00:00
Chris Lattner
18ef3fda57
More refactoring. Move alloca instructions and handle invoke instructions
...
before we delete the original call site, allowing slight simplifications of
code, but nothing exciting.
llvm-svn: 11109
2004-02-04 02:51:48 +00:00
Chris Lattner
9fc977eac4
Move the cloning of the function body much earlier in the inlinefunction
...
process. The only optimization we did so far is to avoid creating a
PHI node, then immediately destroying it in the common case where the
callee has one return statement. Instead, we just don't create the return
value. This has no noticable performance impact, but paves the way for
future improvements.
llvm-svn: 11108
2004-02-04 01:41:09 +00:00
Chris Lattner
a6578ef318
Give CloneBasicBlock an optional function argument to specify which function
...
to add the cloned block to. This allows the block to be added to the function
immediately, and all of the instructions to be immediately added to the function
symbol table, which speeds up the inliner from 3.7 -> 3.38s on the PR209.
llvm-svn: 11107
2004-02-04 01:19:43 +00:00
Chris Lattner
ae51cae111
Bunch up all locally used allocas by the block they are allocated in, and
...
process them all as a group. This speeds up SRoA/mem2reg from 28.46s to
0.62s on the testcase from PR209.
llvm-svn: 11100
2004-02-03 22:34:12 +00:00
Chris Lattner
3784188620
Handle extremely trivial cases extremely efficiently. This speeds up
...
SRoA/mem2reg from 41.2s to 27.5s on the testcase in PR209.
llvm-svn: 11099
2004-02-03 22:00:33 +00:00
Chris Lattner
c2f0aa58df
Disable (x - (y - z)) => (x + (z - y)) optimization for floating point.
...
llvm-svn: 11083
2004-02-02 20:09:56 +00:00
Chris Lattner
cacd30b957
Update comment
...
llvm-svn: 11082
2004-02-02 20:09:22 +00:00
Brian Gaeke
6204e75c4a
Make deadarghaX0r warning louder.
...
(I just love typing haX0r. haX0r haX0r haX0r.)
llvm-svn: 11079
2004-02-02 19:32:27 +00:00
Chris Lattner
ed9b12c31a
Disable tail duplication in any "hard" cases, where it might break SSA form.
...
llvm-svn: 11052
2004-02-01 06:32:28 +00:00
Chris Lattner
7c91a6176c
Fix the count of the number of instructions removed
...
llvm-svn: 11049
2004-02-01 05:15:07 +00:00
Misha Brukman
bf43787f33
Hyphenate `target-dependent'
...
llvm-svn: 11003
2004-01-28 20:43:01 +00:00
Chris Lattner
1f7942fe7d
Fix InstCombine/2004-01-13-InstCombineInvokePHI.ll, which also fixes lots
...
of C++ programs in Shootout-C++, including lists1 and moments, etc
llvm-svn: 10845
2004-01-14 06:06:08 +00:00
Chris Lattner
6b052f2154
Clean up #includes
...
llvm-svn: 10799
2004-01-12 19:56:36 +00:00
Chris Lattner
fcf21a75b0
Fix bug in previous checkin
...
llvm-svn: 10798
2004-01-12 19:47:05 +00:00
Chris Lattner
c1e7cc0fbe
Eliminate use of ConstantHandling and ConstantExpr::getShift interfaces
...
llvm-svn: 10796
2004-01-12 19:35:11 +00:00
Chris Lattner
d7ccc9e5a5
Add header file I accidentally removed in teh shuffle
...
llvm-svn: 10795
2004-01-12 19:15:20 +00:00
Chris Lattner
c9fb4a3b89
Remove use of the ConstantHandling interfaces
...
llvm-svn: 10793
2004-01-12 19:12:50 +00:00
Chris Lattner
429963742e
Remove use of ConstantExpr::getShift
...
llvm-svn: 10792
2004-01-12 19:10:58 +00:00
Chris Lattner
1b7d4d7b63
Don't use ConstantExpr::getShift anymore
...
llvm-svn: 10791
2004-01-12 19:08:43 +00:00
Chris Lattner
2853a7ed22
Remove use of ConstantHandling
...
llvm-svn: 10789
2004-01-12 18:35:03 +00:00
Chris Lattner
118a76cb2f
Remove unneeded #include
...
llvm-svn: 10788
2004-01-12 18:33:54 +00:00
Chris Lattner
fc6c859a0c
Move llvm::ConstantFoldInstruction from VMCore to here, next to ConstantFoldTerminator
...
llvm-svn: 10785
2004-01-12 18:25:22 +00:00
Chris Lattner
81d8822396
Remove uses of ConstantHandling itf
...
llvm-svn: 10783
2004-01-12 18:12:44 +00:00
Chris Lattner
0fe5b32c01
Use constantexprs for casts. Eliminate use of the ConstantHandling interfaces
...
llvm-svn: 10779
2004-01-12 17:43:40 +00:00
Chris Lattner
fe992d4332
Fix fairly severe bug in my last checking where we treated all unfoldable
...
constants as being "true" when evaluating branches. This was introduced
because we now create constantexprs for the constants instead of failing the
fold.
llvm-svn: 10778
2004-01-12 17:40:36 +00:00
Chris Lattner
49f74522ec
* Implement minor performance optimization for the getelementptr case
...
* Implement SCCP of load instructions, implementing Transforms/SCCP/loadtest.ll
This allows us to fold expressions like "foo"[2], even if the pointer is only
a conditional constant.
llvm-svn: 10767
2004-01-12 04:29:41 +00:00
Chris Lattner
7e8af38637
Do not hack on volatile loads. I'm not sure what the point of a volatile load
...
from constant memory is, but lets not take chances.
llvm-svn: 10765
2004-01-12 04:13:56 +00:00
Chris Lattner
05fe6847a8
Implement SCCP/phitest.ll
...
llvm-svn: 10763
2004-01-12 03:57:30 +00:00
Chris Lattner
fafa2ff2d6
Implement Transforms/ScalarRepl/phinodepromote.ll, which is an important
...
case that the C/C++ front-end generates.
llvm-svn: 10761
2004-01-12 01:18:32 +00:00
Chris Lattner
3bcecb92f3
Update obsolete comments
...
Fix iterator invalidation problems which was causing -mstrip to miss some
entries, and read free'd memory. This shrinks the symbol table of 254.gap
from 333 to 284 bytes! :)
llvm-svn: 10751
2004-01-10 21:36:49 +00:00
Chris Lattner
df3c342a4c
Finegrainify namespacification
...
llvm-svn: 10727
2004-01-09 06:12:26 +00:00
Chris Lattner
fdf788eebd
Remove dependence on structure index type. s/MT/FT
...
llvm-svn: 10726
2004-01-09 06:02:51 +00:00
Chris Lattner
49525f8cf4
Finegrainify namespacification
...
llvm-svn: 10725
2004-01-09 06:02:20 +00:00
Chris Lattner
ff66958154
Finegrainify namespacification
...
add flags for PR82
llvm-svn: 10724
2004-01-09 05:53:38 +00:00
Chris Lattner
9cc1a0e40d
Inching towards fixing PR82
...
llvm-svn: 10722
2004-01-09 05:44:50 +00:00
Chris Lattner
59d2d7fc33
Improve encapsulation in the Loop and LoopInfo classes by eliminating the
...
getSubLoops/getTopLevelLoops methods, replacing them with iterator-based
accessors.
llvm-svn: 10714
2004-01-08 00:09:44 +00:00
Chris Lattner
56db5e98c8
Merging constants can cause further room for improvement. Iterate until
...
we converge
llvm-svn: 10618
2003-12-28 07:19:08 +00:00
Chris Lattner
30513e0a3a
rename ClassifyExpression -> ClassifyExpr
...
llvm-svn: 10592
2003-12-23 08:04:08 +00:00
Chris Lattner
7e755e443f
More minor non-functional changes. This now computes the exit condition, though
...
it doesn't do anything with it.
llvm-svn: 10590
2003-12-23 07:47:09 +00:00
Chris Lattner
93bfb6c741
Remove extraneous #include
...
finegrainify namespacification
llvm-svn: 10589
2003-12-23 07:43:38 +00:00
Chris Lattner
c2ee05427e
Fix memory corruption bug PR193
...
llvm-svn: 10586
2003-12-22 23:49:36 +00:00
Chris Lattner
a02d5aa6ce
Don't mind me, I'm just refactoring away. This patch makes room for LFTR, but
...
contains no functionality changes.
llvm-svn: 10583
2003-12-22 09:53:29 +00:00
Chris Lattner
6449dcefbc
Implement IndVarsSimplify/pointer-indvars.ll, transforming pointer
...
arithmetic into "array subscripts"
llvm-svn: 10580
2003-12-22 05:02:01 +00:00
Chris Lattner
d3678bc7c5
Fix PR194
...
llvm-svn: 10573
2003-12-22 03:58:44 +00:00
Chris Lattner
fc7bdac1b3
Fix ADCE/2003-12-19-MergeReturn.llx
...
llvm-svn: 10539
2003-12-19 09:08:34 +00:00
Chris Lattner
918460190f
Remove the wierd "Operands" loop, by traversing basicblocks in reverse order
...
llvm-svn: 10536
2003-12-19 08:18:16 +00:00
Chris Lattner
547192d688
Implement LICM/sink_multiple.ll, by sinking all possible instructions in the
...
loop before hoisting any.
llvm-svn: 10534
2003-12-19 07:22:45 +00:00
Chris Lattner
031a3f8cc7
Generalize a special case to fix PR187
...
llvm-svn: 10531
2003-12-19 06:27:08 +00:00
Chris Lattner
91daeb5431
Factor code out into the Utils library
...
llvm-svn: 10530
2003-12-19 05:58:40 +00:00
Chris Lattner
04efa4b155
Add new function
...
llvm-svn: 10529
2003-12-19 05:56:28 +00:00
John Criswell
b22e9b4b35
Reverted back to previous revision - this was previously merged
...
according to the CVS log messages.
llvm-svn: 10517
2003-12-18 17:19:19 +00:00
John Criswell
86a3a48697
Merged in RELEASE_11.
...
llvm-svn: 10516
2003-12-18 16:43:17 +00:00
Chris Lattner
9e2b42a0c8
When we delete instructions from the loop, make sure to remove them from the
...
AliasSetTracker as well.
llvm-svn: 10507
2003-12-18 08:12:32 +00:00
Chris Lattner
6c08bb8b8e
Fix for PR185 & IndVarsSimplify/2003-12-15-Crash.llx
...
llvm-svn: 10473
2003-12-15 17:34:02 +00:00
Chris Lattner
884e824534
Refactor code just a little bit, allowing us to implement TailCallElim/return_constant.ll
...
llvm-svn: 10467
2003-12-14 23:57:39 +00:00
Chris Lattner
d1c371c32c
Do not promote volatile alias sets into registers
...
llvm-svn: 10458
2003-12-14 04:52:31 +00:00
Chris Lattner
34399dda2d
Fix LICM/2003-12-11-SinkingToPHI.ll, and quite possibly all of the other known problems in the universe.
...
llvm-svn: 10409
2003-12-11 22:23:32 +00:00
Chris Lattner
027253b0d5
verifyFunction depends on dominator info, which levelraise does not declare
...
that it needs. This is pretty scary code! This fixes
Regression.Transforms.LevelRaise.2002-07-16-SourceAndDestCrash
Regression.Transforms.LevelRaise.2002-07-31-AssertionFailure
llvm-svn: 10406
2003-12-11 21:47:37 +00:00
Chris Lattner
6281fd3ead
Fix bug: LICM/sink_multiple_exits.ll
...
Thanks for pointing this out John :)
llvm-svn: 10387
2003-12-10 22:35:56 +00:00
Chris Lattner
55c2113b7b
Don't allow dead instructions to stop sinking early.
...
llvm-svn: 10386
2003-12-10 20:43:29 +00:00
Chris Lattner
713907e2b8
Fix bug: IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx
...
llvm-svn: 10385
2003-12-10 20:43:04 +00:00
Chris Lattner
7e5bd59da2
Finegrainify namespacification
...
Fix bug: LowerInvoke/2003-12-10-Crash.llx
llvm-svn: 10382
2003-12-10 20:22:42 +00:00
Chris Lattner
ccd9f3c1f8
Finegrainify namespacification
...
Reorder #includes
Implement: IndVarsSimplify/2003-12-10-IndVarDeadCode.ll
llvm-svn: 10376
2003-12-10 18:06:47 +00:00
Chris Lattner
7710f2f49e
Finegrainify namespacification
...
Fix bug: LoopSimplify/2003-12-10-ExitBlocksProblem.ll
llvm-svn: 10373
2003-12-10 17:20:35 +00:00
Chris Lattner
6364314a6e
Simplify code
...
llvm-svn: 10371
2003-12-10 16:58:24 +00:00
Chris Lattner
48b4b852b4
Avoid performing two identical lookups when one will suffice
...
llvm-svn: 10370
2003-12-10 16:57:24 +00:00
Chris Lattner
edda1af35a
Make LICM itself a bit more efficient, and make the generated code more efficient too: don't insert a store in every exit block, because a particular block may be exited to more than once by a loop
...
llvm-svn: 10369
2003-12-10 15:56:24 +00:00
Chris Lattner
aaaea51090
Implement instruction sinking out of loops. This still can do a little bit
...
better job, but this is the majority of the work. This implements
LICM/sink*.ll
llvm-svn: 10358
2003-12-10 06:41:05 +00:00
Chris Lattner
6c237bcdf2
Do not insert one entry PHI nodes in split exit blocks!
...
llvm-svn: 10348
2003-12-09 23:12:55 +00:00
Chris Lattner
65c1193d55
Refactor code a little bit, eliminating the gratuitous InstVisitor, which
...
should make subsequent changes simpler. This also allows us to hoist vaarg
and vanext instructions
llvm-svn: 10342
2003-12-09 19:32:44 +00:00
Chris Lattner
c05176843e
Fine grainify namespacification
...
Code cleanups
Make LICM::SafeToHoist marginally more efficient
llvm-svn: 10341
2003-12-09 17:18:00 +00:00
Chris Lattner
50663a1a78
Implement: TailCallElim/accum_recursion_constant_arg.ll
...
Also make sure to clean up any PHI nodes that are inserted which are pointless.
llvm-svn: 10333
2003-12-08 23:37:35 +00:00
Chris Lattner
198e620752
Implement: test/Regression/Transforms/TailCallElim/accum_recursion.ll
...
We now insert accumulator variables as necessary to eliminate tail recursion
more aggressively. This is still fairly limited, but allows us to transform
fib/factorial, and other functions into nice happy loops. :)
llvm-svn: 10332
2003-12-08 23:19:26 +00:00
Chris Lattner
a7b6f3ab9c
Cleanup and restructure the code to make it easier to read and maintain.
...
The only functionality change is that we now implement:
Regression/Transforms/TailCallElim/intervening-inst.ll
Which is really kinda pointless, because it means that trivially dead code
does not interfere with -tce, but trivially dead code probably wouldn't be
around anytime when this pass is run anyway.
The point of including this change it to support other more aggressive
transformations when we have the analysis capabilities to do so.
llvm-svn: 10312
2003-12-08 05:34:54 +00:00
Chris Lattner
771804b541
Implement RaiseAllocations/FreeCastConstantExpr.ll
...
llvm-svn: 10305
2003-12-07 01:42:08 +00:00
Chris Lattner
8427bffb9a
* Finegrainify namespacification
...
* Transform: free <ty>* (cast <ty2>* X to <ty>*) into free <ty2>* X
llvm-svn: 10303
2003-12-07 01:24:23 +00:00
Chris Lattner
40d2aeb28f
Finegrainify namespacification
...
Fix regressions ScalarRepl/basictest.ll & arraytest.ll
llvm-svn: 10287
2003-12-02 17:43:55 +00:00
Chris Lattner
8384f97ee4
Fix test: Transforms/LevelRaise/2003-11-28-IllegalTypeConversion.ll
...
Some gep generalization changes
llvm-svn: 10252
2003-11-29 05:31:25 +00:00
Chris Lattner
52310702a1
Do not use index type to determine what it is indexing into!
...
llvm-svn: 10226
2003-11-25 21:09:18 +00:00
Chris Lattner
28ebb3e0a6
Delete dead line
...
llvm-svn: 10164
2003-11-22 02:26:17 +00:00
Chris Lattner
f40cdbe856
Fix bug: Transforms/PruneEH/2003-11-21-PHIUpdate.llx
...
llvm-svn: 10163
2003-11-22 02:20:36 +00:00
Chris Lattner
4cc2cc5c58
Do not crash when deleing a region with a dead invoke instruction
...
llvm-svn: 10161
2003-11-22 02:13:08 +00:00
Chris Lattner
1ad805977d
Finegrainify namespacification
...
The module stripping pass should not strip symbols on external globals
llvm-svn: 10157
2003-11-22 01:29:35 +00:00
Chris Lattner
61b3f20bf1
Considering that CI is not even IN SCOPE here, I wooda thought the compiler
...
would have caught this. *sigh*
llvm-svn: 10142
2003-11-21 21:57:29 +00:00
Chris Lattner
f52e03c79e
Finegrainify namespacification
...
llvm-svn: 10138
2003-11-21 21:54:22 +00:00