oota-llvm.git
19 years agoImplement the optimizations for "pow" and "fputs" library calls.
Reid Spencer [Fri, 29 Apr 2005 09:39:47 +0000 (09:39 +0000)]
Implement the optimizations for "pow" and "fputs" library calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21618 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd a test case for the puts libcall optimization.
Reid Spencer [Fri, 29 Apr 2005 07:19:00 +0000 (07:19 +0000)]
Add a test case for the puts libcall optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21616 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd a testcase for optimizing the strcpy libcall.
Reid Spencer [Fri, 29 Apr 2005 06:01:28 +0000 (06:01 +0000)]
Add a testcase for optimizing the strcpy libcall.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21615 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoRemove optimizations that don't require both operands to be constant. These
Reid Spencer [Fri, 29 Apr 2005 05:55:35 +0000 (05:55 +0000)]
Remove optimizations that don't require both operands to be constant. These
are moved to simplify-libcalls pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21614 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoNew test case for testing pow(3) math library optimizations.
Reid Spencer [Fri, 29 Apr 2005 05:47:05 +0000 (05:47 +0000)]
New test case for testing pow(3) math library optimizations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21613 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoConsistently use 'class' to silence VC++
Jeff Cohen [Fri, 29 Apr 2005 03:05:44 +0000 (03:05 +0000)]
Consistently use 'class' to silence VC++

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21612 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago* Add constant folding for additional floating point library calls such as
Reid Spencer [Thu, 28 Apr 2005 23:01:59 +0000 (23:01 +0000)]
* Add constant folding for additional floating point library calls such as
  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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21611 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd support for FSQRT node, patch contributed by Morten Ofstad
Chris Lattner [Thu, 28 Apr 2005 22:07:18 +0000 (22:07 +0000)]
Add support for FSQRT node, patch contributed by Morten Ofstad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21610 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoThese functions can set errno!
Chris Lattner [Thu, 28 Apr 2005 21:52:31 +0000 (21:52 +0000)]
These functions can set errno!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21609 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd some new X86 instrs, patch contributed by Morten Ofstad
Chris Lattner [Thu, 28 Apr 2005 21:50:05 +0000 (21:50 +0000)]
Add some new X86 instrs, patch contributed by Morten Ofstad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21608 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoCodegen fabs/fabsf as FABS. Patch contributed by Morten Ofstad
Chris Lattner [Thu, 28 Apr 2005 21:48:42 +0000 (21:48 +0000)]
Codegen fabs/fabsf as FABS.  Patch contributed by Morten Ofstad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21607 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoLegalize FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
Chris Lattner [Thu, 28 Apr 2005 21:44:33 +0000 (21:44 +0000)]
Legalize FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21606 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
Chris Lattner [Thu, 28 Apr 2005 21:44:03 +0000 (21:44 +0000)]
Add FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21605 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoRemove from the TODO list those optimizations that are already handled by
Reid Spencer [Thu, 28 Apr 2005 18:05:16 +0000 (18:05 +0000)]
Remove from the TODO list those optimizations that are already handled by
constant folding implemented in lib/Transforms/Utils/Local.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21604 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoDocument additional libcall transformations that need to be written.
Reid Spencer [Thu, 28 Apr 2005 04:40:06 +0000 (04:40 +0000)]
Document additional libcall transformations that need to be written.

Help Wanted!

There's a lot of them to write.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21603 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoDoxygenate.
Reid Spencer [Wed, 27 Apr 2005 21:29:20 +0000 (21:29 +0000)]
Doxygenate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21602 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoremove 'statement with no effect' warning
Chris Lattner [Wed, 27 Apr 2005 20:12:17 +0000 (20:12 +0000)]
remove 'statement with no effect' warning

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21600 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoImplement Value* tracking for loads and stores in the selection DAG. This enables...
Andrew Lenharth [Wed, 27 Apr 2005 20:10:01 +0000 (20:10 +0000)]
Implement Value* tracking for loads and stores in the selection DAG.  This enables one to use alias analysis in the backends.

(TRUNK)Stores and (EXT|ZEXT|SEXT)Loads have an extra SDOperand which is a SrcValueSDNode which contains the Value*.  Note that if the operation is introduced by the backend, it will still have the operand, but the value* will be null.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21599 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUnbreak the sparc backend.
Chris Lattner [Wed, 27 Apr 2005 18:57:15 +0000 (18:57 +0000)]
Unbreak the sparc backend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21598 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoMore Cleanup:
Reid Spencer [Wed, 27 Apr 2005 17:46:54 +0000 (17:46 +0000)]
More Cleanup:
* Name the instructions by appending to name of original
* Factor common part out of a switch statement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21597 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoimport fix and plot multiple lines at once
Andrew Lenharth [Wed, 27 Apr 2005 17:32:41 +0000 (17:32 +0000)]
import fix and plot multiple lines at once

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21596 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoGenerate a gnuplot script for any program and any test (like llc or gcc)
Andrew Lenharth [Wed, 27 Apr 2005 16:41:50 +0000 (16:41 +0000)]
Generate a gnuplot script for any program and any test (like llc or gcc)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21593 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoSo you want to import nightly tester data into a data base? Have we got the perl...
Andrew Lenharth [Wed, 27 Apr 2005 16:03:01 +0000 (16:03 +0000)]
So you want to import nightly tester data into a data base?  Have we got the perl script for you

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21592 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agofix for parse, and a start at db import. Using CVS as scp :)
Andrew Lenharth [Wed, 27 Apr 2005 14:57:26 +0000 (14:57 +0000)]
fix for parse, and a start at db import.  Using CVS as scp :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21591 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoclean up some warnings
Duraid Madina [Wed, 27 Apr 2005 11:57:39 +0000 (11:57 +0000)]
clean up some warnings

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21590 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoThis is a cleanup commit:
Reid Spencer [Wed, 27 Apr 2005 07:54:40 +0000 (07:54 +0000)]
This is a cleanup commit:
* 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21589 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agodetect functions that never return, and turn the instruction following a
Chris Lattner [Wed, 27 Apr 2005 04:52:23 +0000 (04:52 +0000)]
detect functions that never return, and turn  the instruction following a
call to them into an 'unreachable' instruction.

This triggers a bunch of times, particularly on gcc:

gzip: 36
gcc: 601
eon: 12
bzip: 38

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21587 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoTest the noreturn function optimization
Chris Lattner [Wed, 27 Apr 2005 04:51:01 +0000 (04:51 +0000)]
Test the noreturn function optimization

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21586 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd the simplify-libcalls pass.
Reid Spencer [Wed, 27 Apr 2005 02:22:47 +0000 (02:22 +0000)]
Add the simplify-libcalls pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21585 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoA first step towards being able to do more interesting things with the nightly tester...
Andrew Lenharth [Wed, 27 Apr 2005 02:13:20 +0000 (02:13 +0000)]
A first step towards being able to do more interesting things with the nightly tester data.  Moreinteresting things will come soon, so tune in

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21584 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoPrefix the debug statistics so they group together.
Reid Spencer [Wed, 27 Apr 2005 00:20:23 +0000 (00:20 +0000)]
Prefix the debug statistics so they group together.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21583 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoIn debug builds, make a statistic for each kind of call optimization. This
Reid Spencer [Wed, 27 Apr 2005 00:05:45 +0000 (00:05 +0000)]
In debug builds, make a statistic for each kind of call optimization. This
helps track down what gets triggered in the pass so its easier to identify
good test cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21582 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoThis analysis doesn't take 'throwing' into consideration, it looks at
Chris Lattner [Tue, 26 Apr 2005 23:53:25 +0000 (23:53 +0000)]
This analysis doesn't take 'throwing' into consideration, it looks at
'unwinding'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21581 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFix up the debug statement to actually use a newline .. radical concept.
Reid Spencer [Tue, 26 Apr 2005 23:07:08 +0000 (23:07 +0000)]
Fix up the debug statement to actually use a newline .. radical concept.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21580 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUh, this isn't argpromotion.
Reid Spencer [Tue, 26 Apr 2005 23:05:17 +0000 (23:05 +0000)]
Uh, this isn't argpromotion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21579 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd some debugging output so we can tell which calls are getting triggered
Reid Spencer [Tue, 26 Apr 2005 23:02:16 +0000 (23:02 +0000)]
Add some debugging output so we can tell which calls are getting triggered

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21578 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agono parens
Chris Lattner [Tue, 26 Apr 2005 22:57:07 +0000 (22:57 +0000)]
no parens

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21577 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoupdate some paths
Chris Lattner [Tue, 26 Apr 2005 22:56:16 +0000 (22:56 +0000)]
update some paths

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21576 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoNo, seriously folks, memcpy really does return void.
Reid Spencer [Tue, 26 Apr 2005 22:49:48 +0000 (22:49 +0000)]
No, seriously folks, memcpy really does return void.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21575 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agomemcpy returns void!!!!!
Reid Spencer [Tue, 26 Apr 2005 22:46:23 +0000 (22:46 +0000)]
memcpy returns void!!!!!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21574 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoConvert the remainder of the intrinsic function prototypes to "declare"
Reid Spencer [Tue, 26 Apr 2005 20:50:44 +0000 (20:50 +0000)]
Convert the remainder of the intrinsic function prototypes to "declare"
form from the "call" form.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21573 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUse the declare syntax not the call syntax for intrinsic prototypes so
Reid Spencer [Tue, 26 Apr 2005 20:41:16 +0000 (20:41 +0000)]
Use the declare syntax not the call syntax for intrinsic prototypes so
the uninitiated reader is not confused.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21572 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agodon't let Reid build void*'s :)
Chris Lattner [Tue, 26 Apr 2005 20:03:33 +0000 (20:03 +0000)]
don't let Reid build void*'s :)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21571 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFix some bugs found by running on llvm-test:
Reid Spencer [Tue, 26 Apr 2005 19:55:57 +0000 (19:55 +0000)]
Fix some bugs found by running on llvm-test:
* 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21570 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoChanges From Review Feedback:
Reid Spencer [Tue, 26 Apr 2005 19:13:17 +0000 (19:13 +0000)]
Changes From Review Feedback:
* 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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21569 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd a test case for MemMove.ll
Reid Spencer [Tue, 26 Apr 2005 19:05:51 +0000 (19:05 +0000)]
Add a test case for MemMove.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21568 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoResult of strlen is size_t which is either uint or ulong, not int.
Reid Spencer [Tue, 26 Apr 2005 19:04:46 +0000 (19:04 +0000)]
Result of strlen is size_t which is either uint or ulong, not int.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21567 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoMake interval partition print correctly, patch contributed by
Chris Lattner [Tue, 26 Apr 2005 14:48:28 +0000 (14:48 +0000)]
Make interval partition print correctly, patch contributed by
Vladimir Prus!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21566 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFix the compile failures from last night.
Chris Lattner [Tue, 26 Apr 2005 14:40:41 +0000 (14:40 +0000)]
Fix the compile failures from last night.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21565 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoconstmul bugfix: multiply by 27611 was broken
Duraid Madina [Tue, 26 Apr 2005 09:42:50 +0000 (09:42 +0000)]
constmul bugfix: multiply by 27611 was broken

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21564 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoclean up the code! (oops) lots more cleaning left, however.
Duraid Madina [Tue, 26 Apr 2005 08:43:47 +0000 (08:43 +0000)]
clean up the code! (oops) lots more cleaning left, however.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21563 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago* Merge get_GVInitializer and getCharArrayLength into a single function
Reid Spencer [Tue, 26 Apr 2005 07:45:18 +0000 (07:45 +0000)]
* Merge get_GVInitializer and getCharArrayLength into a single function
  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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21562 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd a new test case for the llvm.memcpy simplification case.
Reid Spencer [Tue, 26 Apr 2005 07:40:40 +0000 (07:40 +0000)]
Add a new test case for the llvm.memcpy simplification case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21561 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago* Add code to reduce multiplies by constant integers to shifts, adds and
Duraid Madina [Tue, 26 Apr 2005 07:23:02 +0000 (07:23 +0000)]
* Add code to reduce multiplies by constant integers to shifts, adds and
  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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21560 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago* Implement StrLenOptimization
Reid Spencer [Tue, 26 Apr 2005 05:24:00 +0000 (05:24 +0000)]
* Implement StrLenOptimization
* Factor out commonalities between StrLenOptimization and StrCatOptimization
* Make sure that signatures return sbyte* not void*

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21559 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago* Add a test case for StrLenOptimization
Reid Spencer [Tue, 26 Apr 2005 05:22:38 +0000 (05:22 +0000)]
* Add a test case for StrLenOptimization
* Rename ExitInMain and StrCat tests so they don't have the date the
  regression was entered since they are feature tests, not regressions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21558 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoIncorporate feedback from Chris:
Reid Spencer [Tue, 26 Apr 2005 03:26:15 +0000 (03:26 +0000)]
Incorporate feedback from Chris:
* 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21555 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd SimplyLibCalls.cpp to VC++ build
Jeff Cohen [Tue, 26 Apr 2005 02:57:49 +0000 (02:57 +0000)]
Add SimplyLibCalls.cpp to VC++ build

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21554 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFix RUN: line to not always pass.
Reid Spencer [Tue, 26 Apr 2005 02:33:25 +0000 (02:33 +0000)]
Fix RUN: line to not always pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21553 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFold (X > -1) | (Y > -1) --> (X&Y > -1)
Chris Lattner [Tue, 26 Apr 2005 01:18:33 +0000 (01:18 +0000)]
Fold  (X >  -1) | (Y >  -1)  -->   (X&Y >  -1)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21552 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoChanges due to code review and new implementation:
Reid Spencer [Mon, 25 Apr 2005 21:20:38 +0000 (21:20 +0000)]
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)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21548 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoimplement some more logical compares with constants, so that:
Chris Lattner [Mon, 25 Apr 2005 21:20:28 +0000 (21:20 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21547 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoLots of changes based on review and new functionality:
Reid Spencer [Mon, 25 Apr 2005 21:11:48 +0000 (21:11 +0000)]
Lots of changes based on review and new functionality:
* Use a \1a

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21546 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUpdate the test case to handle a few more (degenerate) cases and remove
Reid Spencer [Mon, 25 Apr 2005 21:08:34 +0000 (21:08 +0000)]
Update the test case to handle a few more (degenerate) cases and remove
the restriction that it is an XFAIL because it now passes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21545 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoCodegen x < 0 | y < 0 as (x|y) < 0. This allows us to compile this to:
Chris Lattner [Mon, 25 Apr 2005 21:03:25 +0000 (21:03 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21544 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoMake dominates(A,B) work with post dominators. Patch contributed by
Chris Lattner [Mon, 25 Apr 2005 20:50:33 +0000 (20:50 +0000)]
Make dominates(A,B) work with post dominators.  Patch contributed by
Naveen Neelakantam, thanks!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21543 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdded question about turning off all optimizations. I think this has been asked once...
Tanya Lattner [Mon, 25 Apr 2005 20:36:56 +0000 (20:36 +0000)]
Added question about turning off all optimizations. I think this has been asked once or twice.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21542 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoimplement getelementptr.ll:test10
Chris Lattner [Mon, 25 Apr 2005 20:17:30 +0000 (20:17 +0000)]
implement getelementptr.ll:test10

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21541 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agorename fn
Chris Lattner [Mon, 25 Apr 2005 20:17:16 +0000 (20:17 +0000)]
rename fn

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21540 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agonew testcase
Chris Lattner [Mon, 25 Apr 2005 20:17:00 +0000 (20:17 +0000)]
new testcase

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21539 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoCorrectly handle global-argument aliases induced in main
Chris Lattner [Mon, 25 Apr 2005 19:16:31 +0000 (19:16 +0000)]
Correctly handle global-argument aliases induced in main

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21537 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoDon't mess up SCC traversal when a node has null edges out of it.
Chris Lattner [Mon, 25 Apr 2005 19:16:17 +0000 (19:16 +0000)]
Don't mess up SCC traversal when a node has null edges out of it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21536 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agodocument 'opaque' types
Chris Lattner [Mon, 25 Apr 2005 17:34:15 +0000 (17:34 +0000)]
document 'opaque' types

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21535 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAdd feedback from Vikram
Chris Lattner [Mon, 25 Apr 2005 15:47:57 +0000 (15:47 +0000)]
Add feedback from Vikram

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21534 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoMake sure the target buffer is null terminated so we don't blow up
Reid Spencer [Mon, 25 Apr 2005 15:40:35 +0000 (15:40 +0000)]
Make sure the target buffer is null terminated so we don't blow up
strcat when its called.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21533 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoA test case for testing the StrCatOptimizer, currently XFAILed everywhere.
Reid Spencer [Mon, 25 Apr 2005 07:29:30 +0000 (07:29 +0000)]
A test case for testing the StrCatOptimizer, currently XFAILed everywhere.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21532 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoPost-Review Cleanup:
Reid Spencer [Mon, 25 Apr 2005 03:59:26 +0000 (03:59 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21526 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUse the %name rather than the "name" format so those familiar with the
Reid Spencer [Mon, 25 Apr 2005 03:18:19 +0000 (03:18 +0000)]
Use the %name rather than the "name" format so those familiar with the
llvm-dis output don't go blind.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21525 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoShut GCC 4.0 up about classes that have virtual functions but a non-virtual
Reid Spencer [Mon, 25 Apr 2005 02:55:55 +0000 (02:55 +0000)]
Shut GCC 4.0 up about classes that have virtual functions but a non-virtual
destructor. Just add the do-nothing virtual destructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21524 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoDeclare a function to create the SimplifyLibCalls pass.
Reid Spencer [Mon, 25 Apr 2005 02:54:00 +0000 (02:54 +0000)]
Declare a function to create the SimplifyLibCalls pass.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21523 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoA new pass to provide specific optimizations for certain well-known library
Reid Spencer [Mon, 25 Apr 2005 02:53:12 +0000 (02:53 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21522 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoA test case for the the ExitInMain libcall simplification.
Reid Spencer [Mon, 25 Apr 2005 02:50:08 +0000 (02:50 +0000)]
A test case for the the ExitInMain libcall simplification.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21521 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoOlder compilers won't like the inline virtual destructor in the header file
Reid Spencer [Mon, 25 Apr 2005 01:01:35 +0000 (01:01 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21520 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agofix some bugs
Chris Lattner [Mon, 25 Apr 2005 00:38:52 +0000 (00:38 +0000)]
fix some bugs

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21515 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoFix a thinko in the documentation of the splitBasicBlock method. The branch
Reid Spencer [Mon, 25 Apr 2005 00:31:53 +0000 (00:31 +0000)]
Fix a thinko in the documentation of the splitBasicBlock method. The branch
instruction is added to the original block, not the new block.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21513 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoShut GCC 4.0 up about classes with virtual functions but no virtual
Reid Spencer [Sun, 24 Apr 2005 22:27:20 +0000 (22:27 +0000)]
Shut GCC 4.0 up about classes with virtual functions but no virtual
destructor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21510 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoShut GCC 4.0 up when it complains about classes with virtual functions that
Reid Spencer [Sun, 24 Apr 2005 22:20:32 +0000 (22:20 +0000)]
Shut GCC 4.0 up when it complains about classes with virtual functions that
don't have virtual destructors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21507 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoMake this readable for newbies and those who can only understand one set of
Reid Spencer [Sun, 24 Apr 2005 20:56:18 +0000 (20:56 +0000)]
Make this readable for newbies and those who can only understand one set of
grammar rules for the English language.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21503 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoextract has been renamed to llvm-extract to avoid conflicting with another tool
Misha Brukman [Sun, 24 Apr 2005 17:46:58 +0000 (17:46 +0000)]
extract has been renamed to llvm-extract to avoid conflicting with another tool

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21501 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoEliminate cases where we could << by 64, which is undefined in C.
Chris Lattner [Sun, 24 Apr 2005 17:46:05 +0000 (17:46 +0000)]
Eliminate cases where we could << by 64, which is undefined in C.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21500 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoThere are still uses for spaces in Makefiles -- to make text line up together,
Misha Brukman [Sun, 24 Apr 2005 17:43:41 +0000 (17:43 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21499 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoextract has been renamed to llvm-extract to avoid conflicting with another tool
Misha Brukman [Sun, 24 Apr 2005 17:36:05 +0000 (17:36 +0000)]
extract has been renamed to llvm-extract to avoid conflicting with another tool

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21498 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoelisp code to help with LLVM code standards compliance
Misha Brukman [Sun, 24 Apr 2005 17:09:19 +0000 (17:09 +0000)]
elisp code to help with LLVM code standards compliance

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21497 91177308-0d34-0410-b5e6-96231b3b80d8

19 years ago.vimrc file to aid in LLVM coding standards conformance
Misha Brukman [Sun, 24 Apr 2005 17:05:04 +0000 (17:05 +0000)]
.vimrc file to aid in LLVM coding standards conformance

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21496 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoImplement xor.ll:test21: select (not C), A, B -> select C, B, A
Chris Lattner [Sun, 24 Apr 2005 07:30:14 +0000 (07:30 +0000)]
Implement xor.ll:test21:  select (not C), A, B -> select C, B, A

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21495 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoTest that xor/select are folded into a select with inverted operands.
Chris Lattner [Sun, 24 Apr 2005 07:28:53 +0000 (07:28 +0000)]
Test that xor/select are folded into a select with inverted operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21494 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoAllow these methods to take a generic Value* to simplify clients. Use
Chris Lattner [Sun, 24 Apr 2005 07:28:37 +0000 (07:28 +0000)]
Allow these methods to take a generic Value* to simplify clients.  Use
const_cast instead of c casts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21493 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoallow these to take a generic Value*
Chris Lattner [Sun, 24 Apr 2005 07:28:04 +0000 (07:28 +0000)]
allow these to take a generic Value*

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21492 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agoUse getPrimitiveSizeInBits() instead of getPrimitiveSize()*8
Chris Lattner [Sun, 24 Apr 2005 06:59:08 +0000 (06:59 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21491 91177308-0d34-0410-b5e6-96231b3b80d8

19 years agounxfail this.
Chris Lattner [Sun, 24 Apr 2005 06:55:40 +0000 (06:55 +0000)]
unxfail this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21490 91177308-0d34-0410-b5e6-96231b3b80d8