summaryrefslogtreecommitdiffstats
path: root/llvm/lib
Commit message (Collapse)AuthorAgeFilesLines
* * 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
* * Add code to reduce multiplies by constant integers to shifts, adds andDuraid Madina2005-04-261-15/+439
| | | | | | | | | | | | | | | | | | | | | | | | subtracts. This is a very rough and nasty implementation of Lefevre's "pattern finding" algorithm. With a few small changes though, it should end up beating most other methods in common use, regardless of the size of the constant (currently, it's often one or two shifts worse) TODO: rewrite it so it's not hideously ugly (this is a translation from perl, which doesn't help ;) bypass most of it for multiplies by 2^n+1 (eventually) teach it that some combinations of shift+add are cheaper than others (e.g. shladd on ia64, scaled adds on alpha) get it to try multiple booth encodings in search of the cheapest routine make it work for negative constants This is hacked up as a DAG->DAG transform, so once I clean it up I hope it'll be pulled out of here and put somewhere else. The only thing backends should really have to worry about for now is where to draw the line between using this code vs. going ahead and doing an integer multiply anyway. llvm-svn: 21560
* * 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
* Fold (X > -1) | (Y > -1) --> (X&Y > -1)Chris Lattner2005-04-261-1/+3
| | | | llvm-svn: 21552
* 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
* implement some more logical compares with constants, so that:Chris Lattner2005-04-251-7/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Lots of changes based on review and new functionality:Reid Spencer2005-04-251-46/+264
| | | | | | * Use a  llvm-svn: 21546
* Codegen x < 0 | y < 0 as (x|y) < 0. This allows us to compile this to:Chris Lattner2005-04-251-1/+4
| | | | | | | | | | | | | | | | | _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
* Make dominates(A,B) work with post dominators. Patch contributed byChris Lattner2005-04-251-2/+7
| | | | | | Naveen Neelakantam, thanks! llvm-svn: 21543
* implement getelementptr.ll:test10Chris Lattner2005-04-251-1/+19
| | | | llvm-svn: 21541
* Correctly handle global-argument aliases induced in mainChris Lattner2005-04-251-2/+30
| | | | llvm-svn: 21537
* Don't mess up SCC traversal when a node has null edges out of it.Chris Lattner2005-04-251-5/+6
| | | | llvm-svn: 21536
* 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
* Shut GCC 4.0 up about classes that have virtual functions but a non-virtualReid Spencer2005-04-251-0/+4
| | | | | | destructor. Just add the do-nothing virtual destructor. llvm-svn: 21524
* 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
* Older compilers won't like the inline virtual destructor in the header fileReid Spencer2005-04-251-0/+3
| | | | | | so we put the destructor in Pass.cpp and make it non-inline. llvm-svn: 21520
* Shut GCC 4.0 up about classes with virtual functions but no virtualReid Spencer2005-04-241-0/+5
| | | | | | destructor. llvm-svn: 21510
* 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
* Allow these methods to take a generic Value* to simplify clients. UseChris Lattner2005-04-241-11/+12
| | | | | | const_cast instead of c casts. llvm-svn: 21493
* 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
* Fix a bug in my previous checkinChris Lattner2005-04-231-22/+22
| | | | llvm-svn: 21485
* Add a method, remove last use of Type.defChris Lattner2005-04-231-2/+28
| | | | llvm-svn: 21483
* Eliminate tabs and trailing spacesJeff Cohen2005-04-2317-241/+241
| | | | llvm-svn: 21480
* Propagate eq sets through the bu graphs to the cbu and eq graphs, fixingChris Lattner2005-04-231-0/+1
| | | | | | a crash of the sfv on 188.ammp llvm-svn: 21478
* 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
* * Order #includes as per style guideMisha Brukman2005-04-221-6/+5
| | | | | | * Combine multiple ``std::cerr <<'' statements into one for simplicity llvm-svn: 21458
* Convert tabs to spacesMisha Brukman2005-04-223-33/+45
| | | | llvm-svn: 21457
* Silence gcc-4.0.0 warnings.Alkis Evlogimenos2005-04-221-4/+4
| | | | llvm-svn: 21453
* Convert tabs to spacesMisha Brukman2005-04-2216-578/+578
| | | | llvm-svn: 21452
* Implement the --enable-targets= feature of the configure script. The makeReid Spencer2005-04-221-2/+8
| | | | | | | | | variable TARGETS_TO_BUILD is used to determine which targets in lib/Target are built and which libraries are linked into llc. This effectively implements the feature. One item remains: disabling targets in the dejagnu test suite. llvm-svn: 21450
* keep track of max depth statsAndrew Lenharth2005-04-221-2/+6
| | | | llvm-svn: 21446
* Updated dependence analyzer. Fixed numerous bugs. Same stage scheduling, etc.Tanya Lattner2005-04-226-297/+641
| | | | llvm-svn: 21444
* Malloc/Free have mod/ref effects. Do not allow CSE of function calls thatChris Lattner2005-04-221-0/+2
| | | | | | call malloc/free. This fixes PR555. llvm-svn: 21443
* Convert tabs to spacesMisha Brukman2005-04-229-17/+19
| | | | llvm-svn: 21440
* Convert tabs to spacesMisha Brukman2005-04-2213-47/+42
| | | | llvm-svn: 21439
* Remove trailing whitespaceMisha Brukman2005-04-21104-1611/+1611
| | | | llvm-svn: 21427
* * Remove trailing whitespaceMisha Brukman2005-04-2116-262/+263
| | | | | | * Convert tabs to spaces llvm-svn: 21426
* Remove trailing whitespaceMisha Brukman2005-04-21120-3059/+3059
| | | | llvm-svn: 21425
* Remove trailing whitespaceMisha Brukman2005-04-2120-384/+384
| | | | llvm-svn: 21424
* Remove trailing whitespaceMisha Brukman2005-04-2144-411/+411
| | | | llvm-svn: 21422
* * Remove trailing whitespaceMisha Brukman2005-04-214-113/+113
| | | | | | * Convert tabs to spaces llvm-svn: 21421
* Remove trailing whitespaceMisha Brukman2005-04-2137-299/+299
| | | | llvm-svn: 21420
* * Remove trailing whitespaceMisha Brukman2005-04-215-135/+135
| | | | | | * Convert tabs to spaces llvm-svn: 21418
* Remove trailing whitespaceMisha Brukman2005-04-214-241/+241
| | | | llvm-svn: 21417
* Remove trailing whitespaceMisha Brukman2005-04-2141-532/+532
| | | | llvm-svn: 21416
* * Remove trailing whitespaceMisha Brukman2005-04-212-15/+15
| | | | | | * Convert tabs to spaces llvm-svn: 21415
* Match another form of eqvChris Lattner2005-04-211-1/+6
| | | | llvm-svn: 21413
* Handle stores of global address as stores of immediates. Instead of:Chris Lattner2005-04-211-0/+5
| | | | | | | | | | | | | | | test1: movl $N, %eax movl %eax, G ret emit: test1: movl $N, G ret llvm-svn: 21407
OpenPOWER on IntegriCloud