summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make this work with renamed intrinsics.Chris Lattner2006-03-031-26/+25
| | | | llvm-svn: 26482
* fix a bunch of alpha regressions. see bug 709Andrew Lenharth2006-02-151-6/+6
| | | | llvm-svn: 26218
* add a bunch more optimizations for unary double math functionsChris Lattner2006-01-231-18/+78
| | | | llvm-svn: 25530
* Refactor/genericize this, no functionality changeChris Lattner2006-01-231-16/+30
| | | | llvm-svn: 25525
* Make this more efficient in the following ways:Chris Lattner2006-01-221-22/+37
| | | | | | | | | 1. Do not statically construct a map when the program starts up, this is expensive and cannot be optimized. Instead, create a list. 2. Do not insert entries for all function in the module into a hashmap that lives the full life of the compiler. llvm-svn: 25512
* Several non-functionality changing changes:Chris Lattner2006-01-221-311/+151
| | | | | | | | | 1. Use the varargs version of getOrInsertFunction to simplify code. 2. remove #include 3. Reduce the number of #ifdef's. 4. remove extraneous vertical whitespace. llvm-svn: 25508
* For PR696:Reid Spencer2006-01-191-0/+9
| | | | | | | | Don't do floor->floorf conversion if floorf is not available. This checks the compiler's host, not its target, which is incorrect for cross-compilers Not sure that's important as we don't build many cross-compilers. llvm-svn: 25456
* Clean up the FFS optimization code, and make it correctly create the appropriateChris Lattner2006-01-171-41/+43
| | | | | | | unsigned llvm.cttz.* intrinsic, fixing the 2005-05-11-Popcount-ffs-fls regression last night. llvm-svn: 25398
* When a function takes a variable number of pointer arguments, with a zeroJeff Cohen2005-10-231-2/+3
| | | | | | | | | | | | | pointer marking the end of the list, the zero *must* be cast to the pointer type. An un-cast zero is a 32-bit int, and at least on x86_64, gcc will not extend the zero to 64 bits, thus allowing the upper 32 bits to be random junk. The new END_WITH_NULL macro may be used to annotate a such a function so that GCC (version 4 or newer) will detect the use of un-casted zero at compile time. llvm-svn: 23888
* Fold isascii into a simple comparison. This speeds up 197.parser by 7.4%,Chris Lattner2005-09-291-0/+26
| | | | | | bringing the LLC time down to the CBE time. llvm-svn: 23521
* remove a bunch of unneeded stuff, or self evident commentsChris Lattner2005-09-291-45/+6
| | | | llvm-svn: 23519
* Implement a couple of memcmp folds from the todo listChris Lattner2005-09-291-3/+121
| | | | llvm-svn: 23517
* Fix some logic I broke that caused a regression onChris Lattner2005-09-251-3/+5
| | | | | | SimplifyLibCalls/2005-05-20-sprintf-crash.ll llvm-svn: 23430
* Simplify this code a bit by relying on recursive simplification. SupportChris Lattner2005-09-241-51/+43
| | | | | | | | sprintf("%s", P)'s that have uses. s/hasNUses(0)/use_empty()/ llvm-svn: 23425
* Transform floor((double)FLT) -> (double)floorf(FLT), implementingChris Lattner2005-08-241-17/+55
| | | | | | | Regression/Transforms/SimplifyLibCalls/floor.ll. This triggers 19 times in 177.mesa. llvm-svn: 23017
* All stats are "Number of ..."Chris Lattner2005-08-071-1/+1
| | | | llvm-svn: 22694
* ConstantInt::get only works for arguments < 128.Chris Lattner2005-08-011-2/+6
| | | | | | | | | | SimplifyLibCalls probably has to be audited to make sure it does not make this mistake elsewhere. Also, if this code knows that the type will be unsigned, obviously one arm of this is dead. Reid, can you take a look into this further? llvm-svn: 22566
* Eliminate all remaining tabs and trailing spaces.Jeff Cohen2005-07-271-152/+152
| | | | llvm-svn: 22523
* Doh! Forgot to LLVMify the style.John Criswell2005-06-291-2/+0
| | | | llvm-svn: 22312
* Basic fix for PR#591; don't convert an fprintf() to an fwrite() if thereJohn Criswell2005-06-291-0/+9
| | | | | | | | | is a mismatch in their character type pointers (i.e. fprintf() prints an array of ubytes while fwrite() takes an array of sbytes). We can probably do better than this (such as casting the ubyte to an sbyte). llvm-svn: 22310
* Fix a problem with the strcmp optimization checking the wrong string andReid Spencer2005-06-181-13/+16
| | | | | | not casting to the correct type. llvm-svn: 22250
* Make the registration hash_map static. No other module needs it. Also,Reid Spencer2005-05-211-1/+5
| | | | | | document what its for a little better. llvm-svn: 22164
* Adjust the file comment to read a little easier.Reid Spencer2005-05-211-6/+7
| | | | llvm-svn: 22163
* Make sure ... arguments are casted to sbyte* where needed.Reid Spencer2005-05-211-13/+12
| | | | llvm-svn: 22162
* Add a "brief" comment for CastToCStrReid Spencer2005-05-211-0/+1
| | | | llvm-svn: 22161
* Fix mismatched type problem that crashed on cases like this:Chris Lattner2005-05-201-8/+17
| | | | | | | | sprintf(P, "%s", X); Where X is not an sbyte*. This fixes the bug JohnMC reported on llvm-bugs. llvm-svn: 22159
* Don't look for __builtin_ffs, we'll never see it from llvm-gcc and there'sReid Spencer2005-05-151-14/+0
| | | | | | not reason to include it for other front ends. llvm-svn: 22070
* Provide this optimization as well:Reid Spencer2005-05-151-5/+45
| | | | | | ffs(x) -> (x == 0 ? 0 : 1+llvm.cttz(x)) llvm-svn: 22068
* Duh .. you actually have to #include Config/config.h before you can testReid Spencer2005-05-151-0/+1
| | | | | | for one of the values that it defines! llvm-svn: 22058
* Changes for ffs lib call simplification:Reid Spencer2005-05-141-3/+74
| | | | | | | | * Check for availability of ffsll call in configure script * Support ffs, ffsl, and ffsll conversion to constant value if the argument is constant. llvm-svn: 22027
* * Add two strlen optimizations:Reid Spencer2005-05-071-23/+56
| | | | | | | | | | | | strlen(x) != 0 -> *x != 0 strlen(x) == 0 -> *x == 0 * Change nested statistics to use style of other LLVM statistics so that only the name of the optimization (simplify-libcalls) is used as the statistic name, and the description indicates which specific all is optimized. Cuts down on some redundancy and saves a few bytes of space. * Make note of stpcpy optimization that could be done. llvm-svn: 21766
* Don't increment the counter unless the debug flag is set.Reid Spencer2005-05-071-1/+1
| | | | llvm-svn: 21762
* Implement the IsDigitOptimization for simplifying calls to the isdigitReid Spencer2005-05-041-6/+54
| | | | | | | | | | | | | library function: isdigit(chr) -> 0 or 1 if chr is constant isdigit(chr) -> chr - '0' <= 9 otherwise Although there are many calls to isdigit in llvm-test, most of them are compiled away by macros leaving only this: 2 MultiSource/Applications/hexxagon llvm-svn: 21688
* * Correct the function prototypes for some of the functions to match theReid Spencer2005-05-041-9/+172
| | | | | | | | | | | | | | | | | | | | | | actual spec (int -> uint) * Add the ability to get/cache the strlen function prototype. * Make sure generated values are appropriately named for debugging purposes * Add the SPrintFOptimiation for 4 casts of sprintf optimization: sprintf(str,cstr) -> llvm.memcpy(str,cstr) (if cstr has no %) sprintf(str,"") -> store sbyte 0, str sprintf(str,"%s",src) -> llvm.memcpy(str,src) (if src is constant) sprintf(str,"%c",chr) -> store chr, str ; store sbyte 0, str+1 The sprintf optimization didn't fire as much as I had hoped: 2 MultiSource/Applications/SPASS 5 MultiSource/Benchmarks/McCat/18-imp 22 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC 1 MultiSource/Benchmarks/Prolangs-C/assembler 6 MultiSource/Benchmarks/Prolangs-C/unix-smail 2 MultiSource/Benchmarks/mediabench/mpeg2/mpeg2dec llvm-svn: 21679
* Implement optimizations for the strchr and llvm.memset library calls.Reid Spencer2005-05-031-21/+232
| | | | | | | | | | | | | | | Neither of these activated as many times as was hoped: strchr: 9 MultiSource/Applications/siod 1 MultiSource/Applications/d 2 MultiSource/Prolangs-C/archie-client 1 External/SPEC/CINT2000/176.gcc/176.gcc llvm.memset: no hits llvm-svn: 21669
* Avoid garbage output in the statistics display by ensuring that theReid Spencer2005-05-031-18/+34
| | | | | | | | strings passed to Statistic's constructor are not destructable. The stats are printed during static destruction and the SimplifyLibCalls module was getting destructed before the statistics. llvm-svn: 21661
* Add the StrNCmpOptimization which is similar to strcmp.Reid Spencer2005-05-031-13/+101
| | | | | | Unfortunately, this optimization didn't trigger on any llvm-test tests. llvm-svn: 21660
* Implement the fprintf optimization which converts calls like this:Reid Spencer2005-05-021-7/+126
| | | | | | | | | | | | | | | | fprintf(F,"hello") -> fwrite("hello",strlen("hello"),1,F) fprintf(F,"%s","hello") -> fwrite("hello",strlen("hello"),1,F) fprintf(F,"%c",'x') -> fputc('c',F) This optimization fires severals times in llvm-test: 313 MultiSource/Applications/Burg 302 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC 189 MultiSource/Benchmarks/Prolangs-C/mybison 175 MultiSource/Benchmarks/Prolangs-C/football 130 MultiSource/Benchmarks/Prolangs-C/unix-tbl llvm-svn: 21657
* Fix a comment that stated the wrong thing.Reid Spencer2005-04-301-5/+2
| | | | llvm-svn: 21638
* * Don't depend on "guessing" what a FILE* is, just require that the actualReid Spencer2005-04-301-21/+132
| | | | | | | | | | | | | | | | | | | | type be obtained from a CallInst we're optimizing. * Make it possible for getConstantStringLength to return the ConstantArray that it extracts in case the content is needed by an Optimization. * Implement the strcmp optimization * Implement the toascii optimization This pass is now firing several to many times in the following MultiSource tests: Applications/Burg - 7 (strcat,strcpy) Applications/siod - 13 (strcat,strcpy,strlen) Applications/spiff - 120 (exit,fputs,strcat,strcpy,strlen) Applications/treecc - 66 (exit,fputs,strcat,strcpy) Applications/kimwitu++ - 34 (strcmp,strcpy,strlen) Applications/SPASS - 588 (exit,fputs,strcat,strcpy,strlen) llvm-svn: 21626
* Implement the optimizations for "pow" and "fputs" library calls.Reid Spencer2005-04-291-17/+217
| | | | llvm-svn: 21618
* Consistently use 'class' to silence VC++Jeff Cohen2005-04-291-2/+4
| | | | llvm-svn: 21612
* 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
* 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
* 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
* Fix up the debug statement to actually use a newline .. radical concept.Reid Spencer2005-04-261-1/+1
| | | | llvm-svn: 21580
OpenPOWER on IntegriCloud