Chris Lattner
15bcc5273b
Fold (X > -1) | (Y > -1) --> (X&Y > -1)
...
llvm-svn: 21552
2005-04-26 01:18:33 +00:00
Reid Spencer
5fcce35fa8
Changes due to code review and new implementation:
...
* Don't use std::string for the function names, const char* will suffice
* Allow each CallOptimizer to validate the function signature before
doing anything
* Repeatedly loop over the functions until an iteration produces
no more optimizations. This allows one optimization to insert a
call that is optimized by another optimization.
* Implement the ConstantArray portion of the StrCatOptimization
* Provide a template for the MemCpyOptimization
* Make ExitInMainOptimization split the block, not delete everything
after the return instruction.
(This covers revision 1.3 and 1.4, as the 1.3 comments were botched)
llvm-svn: 21548
2005-04-25 21:20:38 +00:00
Chris Lattner
d8ac4da793
implement some more logical compares with constants, so that:
...
int foo1(int x, int y) {
int t1 = x >= 0;
int t2 = y >= 0;
return t1 & t2;
}
int foo2(int x, int y) {
int t1 = x == -1;
int t2 = y == -1;
return t1 & t2;
}
produces:
_foo1:
or r2, r4, r3
srwi r2, r2, 31
xori r3, r2, 1
blr
_foo2:
and r2, r4, r3
addic r2, r2, 1
li r2, 0
addze r3, r2
blr
instead of:
_foo1:
srwi r2, r4, 31
xori r2, r2, 1
srwi r3, r3, 31
xori r3, r3, 1
and r3, r2, r3
blr
_foo2:
addic r2, r4, 1
li r2, 0
addze r2, r2
addic r3, r3, 1
li r3, 0
addze r3, r3
and r3, r2, r3
blr
llvm-svn: 21547
2005-04-25 21:20:28 +00:00
Reid Spencer
9b66533e40
Lots of changes based on review and new functionality:
...
* Use a
llvm-svn: 21546
2005-04-25 21:11:48 +00:00
Reid Spencer
2be469978f
Update the test case to handle a few more (degenerate) cases and remove
...
the restriction that it is an XFAIL because it now passes.
llvm-svn: 21545
2005-04-25 21:08:34 +00:00
Chris Lattner
7931b75a81
Codegen x < 0 | y < 0 as (x|y) < 0. This allows us to compile this to:
...
_foo:
or r2, r4, r3
srwi r3, r2, 31
blr
instead of:
_foo:
srwi r2, r4, 31
srwi r3, r3, 31
or r3, r2, r3
blr
llvm-svn: 21544
2005-04-25 21:03:25 +00:00
Chris Lattner
3aff97254e
Make dominates(A,B) work with post dominators. Patch contributed by
...
Naveen Neelakantam, thanks!
llvm-svn: 21543
2005-04-25 20:50:33 +00:00
Tanya Lattner
95c14163f6
Added question about turning off all optimizations. I think this has been asked once or twice.
...
llvm-svn: 21542
2005-04-25 20:36:56 +00:00
Chris Lattner
3f22e5ba5d
implement getelementptr.ll:test10
...
llvm-svn: 21541
2005-04-25 20:17:30 +00:00
Chris Lattner
615fe53900
rename fn
...
llvm-svn: 21540
2005-04-25 20:17:16 +00:00
Chris Lattner
dfeb32d08b
new testcase
...
llvm-svn: 21539
2005-04-25 20:17:00 +00:00
Chris Lattner
bab9c90db4
Correctly handle global-argument aliases induced in main
...
llvm-svn: 21537
2005-04-25 19:16:31 +00:00
Chris Lattner
e39652d21c
Don't mess up SCC traversal when a node has null edges out of it.
...
llvm-svn: 21536
2005-04-25 19:16:17 +00:00
Chris Lattner
641c541312
document 'opaque' types
...
llvm-svn: 21535
2005-04-25 17:34:15 +00:00
Chris Lattner
86e4e676a7
Add feedback from Vikram
...
llvm-svn: 21534
2005-04-25 15:47:57 +00:00
Reid Spencer
7b130447d0
Make sure the target buffer is null terminated so we don't blow up
...
strcat when its called.
llvm-svn: 21533
2005-04-25 15:40:35 +00:00
Reid Spencer
cffd5bc2f3
A test case for testing the StrCatOptimizer, currently XFAILed everywhere.
...
llvm-svn: 21532
2005-04-25 07:29:30 +00:00
Reid Spencer
4b4864684a
Post-Review Cleanup:
...
* Fix comments at top of file
* Change algorithm for running the call optimizations from n*n to something
closer to n.
* Use a hash_map to store and lookup the optimizations since there will
eventually (or potentially) be a large number of them. This gets lookup
based on the name of the function to O(1). Each CallOptimizer now has a
std::string member named func_name that tracks the name of the function
that it applies to. It is this string that is entered into the hash_map
for fast comparison against the function names encountered in the module.
* Cleanup some style issues pertaining to iterator invalidation
* Don't pass the Function pointer to the OptimizeCall function because if
the optimization needs it, it can get it from the CallInst passed in.
* Add the skeleton for a new CallOptimizer, StrCatOptimizer which will
eventually replace strcat's of constant strings with direct copies.
llvm-svn: 21526
2005-04-25 03:59:26 +00:00
Reid Spencer
91f63c0b61
Use the %name rather than the "name" format so those familiar with the
...
llvm-dis output don't go blind.
llvm-svn: 21525
2005-04-25 03:18:19 +00:00
Reid Spencer
e952b16f37
Shut GCC 4.0 up about classes that have virtual functions but a non-virtual
...
destructor. Just add the do-nothing virtual destructor.
llvm-svn: 21524
2005-04-25 02:55:55 +00:00
Reid Spencer
a8e0496412
Declare a function to create the SimplifyLibCalls pass.
...
llvm-svn: 21523
2005-04-25 02:54:00 +00:00
Reid Spencer
95a0d8af78
A new pass to provide specific optimizations for certain well-known library
...
calls. The pass visits all external functions in the module and determines
if such function calls can be optimized. The optimizations are specific to
the library calls involved. This initial version only optimizes calls to
exit(3) when they occur in main(): it changes them to ret instructions.
llvm-svn: 21522
2005-04-25 02:53:12 +00:00
Reid Spencer
c87c21af3d
A test case for the the ExitInMain libcall simplification.
...
llvm-svn: 21521
2005-04-25 02:50:08 +00:00
Reid Spencer
27134f31f2
Older compilers won't like the inline virtual destructor in the header file
...
so we put the destructor in Pass.cpp and make it non-inline.
llvm-svn: 21520
2005-04-25 01:01:35 +00:00
Chris Lattner
ad1a80d7d6
fix some bugs
...
llvm-svn: 21515
2005-04-25 00:38:52 +00:00
Reid Spencer
a37ffe4c46
Fix a thinko in the documentation of the splitBasicBlock method. The branch
...
instruction is added to the original block, not the new block.
llvm-svn: 21513
2005-04-25 00:31:53 +00:00
Reid Spencer
c206223e65
Shut GCC 4.0 up about classes with virtual functions but no virtual
...
destructor.
llvm-svn: 21510
2005-04-24 22:27:20 +00:00
Reid Spencer
2a1b7a35ea
Shut GCC 4.0 up when it complains about classes with virtual functions that
...
don't have virtual destructors.
llvm-svn: 21507
2005-04-24 22:20:32 +00:00
Reid Spencer
9bb0fbd3a2
Make this readable for newbies and those who can only understand one set of
...
grammar rules for the English language.
llvm-svn: 21503
2005-04-24 20:56:18 +00:00
Misha Brukman
b4a985dcc0
extract has been renamed to llvm-extract to avoid conflicting with another tool
...
llvm-svn: 21501
2005-04-24 17:46:58 +00:00
Chris Lattner
e78ae0e1b1
Eliminate cases where we could << by 64, which is undefined in C.
...
llvm-svn: 21500
2005-04-24 17:46:05 +00:00
Misha Brukman
e33c68918a
There are still uses for spaces in Makefiles -- to make text line up together,
...
regardless of the tab size/stop settings on the developer side
llvm-svn: 21499
2005-04-24 17:43:41 +00:00
Misha Brukman
328b40490c
extract has been renamed to llvm-extract to avoid conflicting with another tool
...
llvm-svn: 21498
2005-04-24 17:36:05 +00:00
Misha Brukman
307bcc5132
elisp code to help with LLVM code standards compliance
...
llvm-svn: 21497
2005-04-24 17:09:19 +00:00
Misha Brukman
a08005297f
.vimrc file to aid in LLVM coding standards conformance
...
llvm-svn: 21496
2005-04-24 17:05:04 +00:00
Chris Lattner
5fdcc49858
Implement xor.ll:test21: select (not C), A, B -> select C, B, A
...
llvm-svn: 21495
2005-04-24 07:30:14 +00:00
Chris Lattner
86af6b1fba
Test that xor/select are folded into a select with inverted operands.
...
llvm-svn: 21494
2005-04-24 07:28:53 +00:00
Chris Lattner
a9f3e89328
Allow these methods to take a generic Value* to simplify clients. Use
...
const_cast instead of c casts.
llvm-svn: 21493
2005-04-24 07:28:37 +00:00
Chris Lattner
d40a7efbbb
allow these to take a generic Value*
...
llvm-svn: 21492
2005-04-24 07:28:04 +00:00
Chris Lattner
26c5e79151
Use getPrimitiveSizeInBits() instead of getPrimitiveSize()*8
...
Completely rework the 'setcc (cast x to larger), y' code. This code has
the advantage of implementing setcc.ll:test19 (being more general than
the previous code) and being correct in all cases.
This allows us to unxfail 2004-11-27-SetCCForCastLargerAndConstant.ll,
and close PR454.
llvm-svn: 21491
2005-04-24 06:59:08 +00:00
Chris Lattner
3bf87c4b02
unxfail this.
...
llvm-svn: 21490
2005-04-24 06:55:40 +00:00
Chris Lattner
f492b44ee9
add a new testcase which occurs in 181.mcf
...
llvm-svn: 21489
2005-04-24 06:55:33 +00:00
Misha Brukman
353d27c5fc
* The aesthetic police is on patrol!!...
...
* ... but it wasn't so busy as to not smell the roses and doxygenify comments
llvm-svn: 21487
2005-04-23 22:35:26 +00:00
Chris Lattner
9484bc95af
Add a helper method
...
llvm-svn: 21486
2005-04-23 22:20:22 +00:00
Chris Lattner
dfae677997
Fix a bug in my previous checkin
...
llvm-svn: 21485
2005-04-23 22:01:39 +00:00
Chris Lattner
1fb1ee2b08
This file is never referenced
...
llvm-svn: 21484
2005-04-23 22:00:26 +00:00
Chris Lattner
d10f1f55f9
Add a method, remove last use of Type.def
...
llvm-svn: 21483
2005-04-23 22:00:09 +00:00
Chris Lattner
c40ae24342
add a method, remove a dead #include
...
llvm-svn: 21482
2005-04-23 21:59:42 +00:00
Chris Lattner
2c241870ec
Types.def is going away
...
llvm-svn: 21481
2005-04-23 21:59:11 +00:00
Jeff Cohen
6c42217055
Eliminate tabs and trailing spaces
...
llvm-svn: 21480
2005-04-23 21:38:35 +00:00