summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Consistently use 'class' to silence VC++Jeff Cohen2005-04-291-2/+4
| | | | llvm-svn: 21612
* * Add constant folding for additional floating point library calls such asReid Spencer2005-04-281-26/+90
| | | | | | | | sinh, cosh, etc. * Make the name comparisons for the fp libcalls a little more efficient by switching on the first character of the name before doing comparisons. llvm-svn: 21611
* Remove from the TODO list those optimizations that are already handled byReid Spencer2005-04-281-29/+1
| | | | | | constant folding implemented in lib/Transforms/Utils/Local.cpp. llvm-svn: 21604
* Document additional libcall transformations that need to be written.Reid Spencer2005-04-281-2/+183
| | | | | | | | Help Wanted! There's a lot of them to write. llvm-svn: 21603
* Doxygenate.Reid Spencer2005-04-271-54/+71
| | | | llvm-svn: 21602
* remove 'statement with no effect' warningChris Lattner2005-04-271-1/+1
| | | | llvm-svn: 21600
* More Cleanup:Reid Spencer2005-04-271-28/+26
| | | | | | | * Name the instructions by appending to name of original * Factor common part out of a switch statement. llvm-svn: 21597
* This is a cleanup commit:Reid Spencer2005-04-271-305/+410
| | | | | | | | | | | | | | | | | | | | | | | | * Correct stale documentation in a few places * Re-order the file to better associate things and reduce line count * Make the pass thread safe by caching the Function* objects needed by the optimizers in the pass object instead of globally. * Provide the SimplifyLibCalls pass object to the optimizer classes so they can access cached Function* objects and TargetData info * Make sure the pass resets its cache if the Module passed to runOnModule changes * Rename CallOptimizer LibCallOptimization. All the classes are named *Optimization while the objects are *Optimizer. * Don't cache Function* in the optimizer objects because they could be used by multiple PassManager's running in multiple threads * Add an optimization for strcpy which is similar to strcat * Add a "TODO" list at the end of the file for ideas on additional libcall optimizations that could be added (get ideas from other compilers). Sorry for the huge diff. Its mostly reorganization of code. That won't happen again as I believe the design and infrastructure for this pass is now done or close to it. llvm-svn: 21589
* detect functions that never return, and turn the instruction following aChris Lattner2005-04-271-50/+143
| | | | | | | | | | | | call to them into an 'unreachable' instruction. This triggers a bunch of times, particularly on gcc: gzip: 36 gcc: 601 eon: 12 bzip: 38 llvm-svn: 21587
* Prefix the debug statistics so they group together.Reid Spencer2005-04-271-1/+3
| | | | llvm-svn: 21583
* In debug builds, make a statistic for each kind of call optimization. ThisReid Spencer2005-04-271-21/+35
| | | | | | | helps track down what gets triggered in the pass so its easier to identify good test cases. llvm-svn: 21582
* This analysis doesn't take 'throwing' into consideration, it looks atChris Lattner2005-04-261-13/+13
| | | | | | 'unwinding' llvm-svn: 21581
* Fix up the debug statement to actually use a newline .. radical concept.Reid Spencer2005-04-261-1/+1
| | | | llvm-svn: 21580
* Uh, this isn't argpromotion.Reid Spencer2005-04-261-1/+1
| | | | llvm-svn: 21579
* Add some debugging output so we can tell which calls are getting triggeredReid Spencer2005-04-261-7/+9
| | | | llvm-svn: 21578
* No, seriously folks, memcpy really does return void.Reid Spencer2005-04-261-1/+1
| | | | llvm-svn: 21575
* memcpy returns void!!!!!Reid Spencer2005-04-261-8/+2
| | | | llvm-svn: 21574
* Fix some bugs found by running on llvm-test:Reid Spencer2005-04-261-9/+17
| | | | | | | | | * MemCpyOptimization can only be optimized if the 3rd and 4th arguments are constants and we weren't checking for that. * The result of llvm.memcpy (and llvm.memmove) is void* not sbyte*, put in a cast. llvm-svn: 21570
* Changes From Review Feedback:Reid Spencer2005-04-261-97/+122
| | | | | | | | | | | | | | | | | * Have the SimplifyLibCalls pass acquire the TargetData and pass it down to the optimization classes so they can use it to make better choices for the signatures of functions, etc. * Rearrange the code a little so the utility functions are closer to their usage and keep the core of the pass near the top of the files. * Adjust the StrLen pass to get/use the correct prototype depending on the TargetData::getIntPtrType() result. The result of strlen is size_t which could be either uint or ulong depending on the platform. * Clean up some coding nits (cast vs. dyn_cast, remove redundant items from a switch, etc.) * Implement the MemMoveOptimization as a twin of MemCpyOptimization (they only differ in name). llvm-svn: 21569
* Fix the compile failures from last night.Chris Lattner2005-04-261-0/+2
| | | | llvm-svn: 21565
* * Merge get_GVInitializer and getCharArrayLength into a single functionReid Spencer2005-04-261-136/+151
| | | | | | | | | | | | | | | | named getConstantStringLength. This is the common part of StrCpy and StrLen optimizations and probably several others, yet to be written. It performs all the validity checks for looking at constant arrays that are supposed to be null-terminated strings and then computes the actual length of the string. * Implement the MemCpyOptimization class. This just turns memcpy of 1, 2, 4 and 8 byte data blocks that are properly aligned on those boundaries into a load and a store. Much more could be done here but alignment restrictions and lack of knowledge of the target instruction set prevent use from doing significantly more. That will have to be delegated to the code generators as they lower llvm.memcpy calls. llvm-svn: 21562
* * Implement StrLenOptimizationReid Spencer2005-04-261-52/+137
| | | | | | | * Factor out commonalities between StrLenOptimization and StrCatOptimization * Make sure that signatures return sbyte* not void* llvm-svn: 21559
* Incorporate feedback from Chris:Reid Spencer2005-04-261-102/+184
| | | | | | | | | | | | | | | | | | | | | * Change signatures of OptimizeCall and ValidateCalledFunction so they are non-const, allowing the optimization object to be modified. This is in support of caching things used across multiple calls. * Provide two functions for constructing and caching function types * Modify the StrCatOptimization to cache Function objects for strlen and llvm.memcpy so it doesn't regenerate them on each call site. Make sure these are invalidated each time we start the pass. * Handle both a GEP Instruction and a GEP ConstantExpr * Add additional checks to make sure we really are dealing with an arary of sbyte and that all the element initializers are ConstantInt or ConstantExpr that reduce to ConstantInt. * Make sure the GlobalVariable is constant! * Don't use ConstantArray::getString as it can fail and it doesn't give us the right thing. We must check for null bytes in the middle of the array. * Use llvm.memcpy instead of memcpy so we can factor alignment into it. * Don't use void* types in signatures, replace with sbyte* instead. llvm-svn: 21555
* Changes due to code review and new implementation:Reid Spencer2005-04-251-4/+1
| | | | | | | | | | | | | | | | * 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
* Lots of changes based on review and new functionality:Reid Spencer2005-04-251-46/+264
| | | | | | * Use a  llvm-svn: 21546
* implement getelementptr.ll:test10Chris Lattner2005-04-251-1/+19
| | | | llvm-svn: 21541
* Post-Review Cleanup:Reid Spencer2005-04-251-51/+68
| | | | | | | | | | | | | | | | | | | * 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
* A new pass to provide specific optimizations for certain well-known libraryReid Spencer2005-04-251-0/+167
| | | | | | | | | 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
* Eliminate cases where we could << by 64, which is undefined in C.Chris Lattner2005-04-241-9/+5
| | | | llvm-svn: 21500
* Implement xor.ll:test21: select (not C), A, B -> select C, B, AChris Lattner2005-04-241-2/+10
| | | | llvm-svn: 21495
* Use getPrimitiveSizeInBits() instead of getPrimitiveSize()*8Chris Lattner2005-04-241-170/+160
| | | | | | | | | | | 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
* Eliminate tabs and trailing spacesJeff Cohen2005-04-2315-237/+237
| | | | llvm-svn: 21480
* Generalize the setcc -> PHI and Select folding optimizations to work withChris Lattner2005-04-231-30/+37
| | | | | | | any constant RHS, not just a constant integer RHS. This implements select.ll:test17 llvm-svn: 21470
* Remove trailing whitespaceMisha Brukman2005-04-2182-1225/+1225
| | | | llvm-svn: 21427
* Fix a bug where we would not promote calls to invokes if they occured inChris Lattner2005-04-211-3/+5
| | | | | | the same block as the setjmp. Thanks to Greg Pettyjohn for noticing this! llvm-svn: 21403
* Improve doxygen documentation, patch contributed by Evan Jones!Chris Lattner2005-04-211-17/+17
| | | | llvm-svn: 21393
* Instcombine this:Chris Lattner2005-04-211-0/+3
| | | | | | | | | | | | | | | | | %shortcirc_val = select bool %tmp.1, bool true, bool %tmp.4 ; <bool> [#uses=1] %tmp.6 = cast bool %shortcirc_val to int ; <int> [#uses=1] into this: %shortcirc_val = or bool %tmp.1, %tmp.4 ; <bool> [#uses=1] %tmp.6 = cast bool %shortcirc_val to int ; <int> [#uses=1] not this: %tmp.4.cast = cast bool %tmp.4 to int ; <int> [#uses=1] %tmp.6 = select bool %tmp.1, int 1, int %tmp.4.cast ; <int> [#uses=1] llvm-svn: 21389
* Teach simplifycfg that setcc is cheap and non-trapping, so that it canChris Lattner2005-04-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | convert this: %tmp.1 = seteq int %i, 0 ; <bool> [#uses=1] br bool %tmp.1, label %shortcirc_done, label %shortcirc_next shortcirc_next: ; preds = %entry %tmp.4 = seteq int %j, 0 ; <bool> [#uses=1] br label %shortcirc_done shortcirc_done: ; preds = %shortcirc_next, %entry %shortcirc_val = phi bool [ %tmp.4, %shortcirc_next ], [ true, %entry ] ; <bool> [#uses=1] to this: %tmp.1 = seteq int %i, 0 ; <bool> [#uses=1] %tmp.4 = seteq int %j, 0 ; <bool> [#uses=1] %shortcirc_val = select bool %tmp.1, bool true, bool %tmp.4 ; <bool> [#uses=1] ... which is later simplified by instcombine into an or. llvm-svn: 21388
* Wrap some long lines.Chris Lattner2005-04-191-3/+9
| | | | | | | | Make IPSCCP strip off dead constant exprs that are using functions, making them appear as though their address is taken. This allows us to propagate some more pool descriptors, lowering the overhead of pool alloc. llvm-svn: 21363
* Eliminate a broken transformation, fixing PR548Chris Lattner2005-04-191-4/+2
| | | | llvm-svn: 21354
* silence a bogus warningChris Lattner2005-04-181-1/+1
| | | | llvm-svn: 21320
* a new simple pass, which will be extended to be more useful in the future.Chris Lattner2005-04-151-0/+213
| | | | | | | | | This pass forward branches through conditions when it can show that the conditions is either always true or false for a predecessor. This currently only handles the most simple cases of this, but is successful at threading across 2489 branches and 65 switch instructions in 176.gcc, which isn't bad. llvm-svn: 21306
* Get rid of this for_each loopChris Lattner2005-04-121-2/+2
| | | | llvm-svn: 21253
* Fix bug: InstCombine/2005-05-07-UDivSelectCrash.llChris Lattner2005-04-081-14/+16
| | | | llvm-svn: 21152
* Implement the following xforms:Chris Lattner2005-04-071-3/+18
| | | | | | | | (X-Y)-X --> -Y A + (B - A) --> B (B - A) + A --> B llvm-svn: 21138
* Implement InstCombine/add.ll:test28, transforming C1-(X+C2) --> (C1-C2)-X.Chris Lattner2005-04-071-2/+8
| | | | | | | This occurs several dozen times in specint2k, particularly in crafty and gcc apparently. llvm-svn: 21136
* Transform X-(X+Y) == -Y and X-(Y+X) == -YChris Lattner2005-04-071-2/+11
| | | | llvm-svn: 21134
* disable this transformation in the one obscure case that really pessimizesChris Lattner2005-03-291-0/+3
| | | | | | pointer analysis. llvm-svn: 20916
* Rename createPromoteMemoryToRegister() toAlkis Evlogimenos2005-03-281-2/+1
| | | | | | | createPromoteMemoryToRegisterPass() to be consistent with other pass creation functions. llvm-svn: 20885
* Enhance loopsimplify to preserve alias analysis instead of clobbering it.Chris Lattner2005-03-251-2/+15
| | | | | | This prevents crashes on some programs when using -ds-aa -licm. llvm-svn: 20831
OpenPOWER on IntegriCloud