Commit Graph

1914 Commits

Author SHA1 Message Date
Reid Spencer
20754ac069 * 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
2005-04-26 07:45:18 +00:00
Reid Spencer
912401c3f6 * 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
2005-04-26 05:24:00 +00:00
Reid Spencer
43e0baece3 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
2005-04-26 03:26:15 +00:00
Reid Spencer
855adb1ac4 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
2005-04-25 21:20:38 +00:00
Reid Spencer
6cc0311c6d Lots of changes based on review and new functionality:
* Use a 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21546 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 21:11:48 +00:00
Chris Lattner
a70b66d49e implement getelementptr.ll:test10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21541 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 20:17:30 +00:00
Reid Spencer
b7c11e3966 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
2005-04-25 03:59:26 +00:00
Reid Spencer
a7c049bf6a 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
2005-04-25 02:53:12 +00:00
Chris Lattner
f52d681657 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
2005-04-24 17:46:05 +00:00
Chris Lattner
a1df33c0ee 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
2005-04-24 07:30:14 +00:00
Chris Lattner
484d3cf0e3 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
2005-04-24 06:59:08 +00:00
Jeff Cohen
9d80930e95 Eliminate tabs and trailing spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21480 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-23 21:38:35 +00:00
Chris Lattner
6970b661cb Generalize the setcc -> PHI and Select folding optimizations to work with
any constant RHS, not just a constant integer RHS.  This implements
select.ll:test17


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21470 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-23 15:31:55 +00:00
Misha Brukman
fd93908ae8 Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21427 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 23:48:37 +00:00
Chris Lattner
cb2d1a2dc2 Fix a bug where we would not promote calls to invokes if they occured in
the same block as the setjmp.  Thanks to Greg Pettyjohn for noticing this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21403 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 16:46:46 +00:00
Chris Lattner
0f67dd6237 Improve doxygen documentation, patch contributed by Evan Jones!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21393 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 16:04:49 +00:00
Chris Lattner
956db27a63 Instcombine this:
%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]


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21389 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 05:43:13 +00:00
Chris Lattner
bf5d4fb7d8 Teach simplifycfg that setcc is cheap and non-trapping, so that it can
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21388 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 05:31:13 +00:00
Chris Lattner
7d27fc0252 Wrap some long lines.
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21363 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-19 19:16:19 +00:00
Chris Lattner
240d6f4c9d Eliminate a broken transformation, fixing PR548
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21354 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-19 06:04:18 +00:00
Chris Lattner
ea96b5edbb silence a bogus warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21320 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 05:26:21 +00:00
Chris Lattner
36d12733bb a new simple pass, which will be extended to be more useful in the future.
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21306 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-15 19:28:32 +00:00
Chris Lattner
151c80be81 Get rid of this for_each loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21253 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 18:51:33 +00:00
Chris Lattner
bf70b838e7 Fix bug: InstCombine/2005-05-07-UDivSelectCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21152 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-08 04:03:26 +00:00
Chris Lattner
7edc8c223e Implement the following xforms:
(X-Y)-X --> -Y
A + (B - A) --> B
(B - A) + A --> B


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21138 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-07 17:14:51 +00:00
Chris Lattner
08954a26e4 Implement InstCombine/add.ll:test28, transforming C1-(X+C2) --> (C1-C2)-X.
This occurs several dozen times in specint2k, particularly in crafty and gcc
apparently.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21136 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-07 16:28:01 +00:00
Chris Lattner
43d84d6b71 Transform X-(X+Y) == -Y and X-(Y+X) == -Y
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21134 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-07 16:15:25 +00:00
Chris Lattner
b1515fe522 disable this transformation in the one obscure case that really pessimizes
pointer analysis.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20916 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-29 06:37:47 +00:00
Alkis Evlogimenos
ab7ada3ed6 Rename createPromoteMemoryToRegister() to
createPromoteMemoryToRegisterPass() to be consistent with other pass
creation functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20885 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-28 02:01:12 +00:00
Chris Lattner
cec5b8831d Enhance loopsimplify to preserve alias analysis instead of clobbering it.
This prevents crashes on some programs when using -ds-aa -licm.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20831 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-25 06:37:22 +00:00
Chris Lattner
70ac2dcb84 Fix a bug where LICM was not updating AA information properly when sinking
a pointer value out of a loop causing it to be duplicated.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20828 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-25 00:22:36 +00:00
Chris Lattner
1f309c1a4e enable -debug-only=licm
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20788 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-23 21:00:12 +00:00
Chris Lattner
5b3a4553c1 Fix the missing symbols problem Bill was hitting. Patch contributed by
Bill Wendling!!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20649 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-17 15:38:16 +00:00
Chris Lattner
feb1550824 stop using method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20603 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-15 05:19:49 +00:00
Chris Lattner
e4d5c441e0 This mega patch converts us from using Function::a{iterator|begin|end} to
using Function::arg_{iterator|begin|end}.  Likewise Module::g* -> Module::global_*.

This patch is contributed by Gabor Greif, thanks!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20597 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-15 04:54:21 +00:00
Chris Lattner
2f62fdc9a7 fix a bug where we thought arguments were constants :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20506 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 22:52:29 +00:00
Chris Lattner
3f93197098 Fix Regression/Transforms/LoopStrengthReduce/dont_insert_redundant_ops.ll,
hopefully not breaking too many other things.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20505 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 22:36:12 +00:00
Chris Lattner
2f9b19b4c9 implement Transforms/LoopStrengthReduce/invariant_value_first_arg.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20501 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 22:06:22 +00:00
Chris Lattner
2461dff070 minor simplifications of the code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20497 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 21:58:22 +00:00
Chris Lattner
fee3411379 trivial simplification
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20494 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 21:35:38 +00:00
Chris Lattner
decc86db0c Fix a bug where we could corrupt a parent loop's header info if we unrolled
a nested loop.  This fixes Transforms/LoopUnroll/2005-03-06-BadLoopInfoUpdate.ll
and PR532


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20493 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 20:57:32 +00:00
Chris Lattner
82aa566795 Make this MUCH faster by avoiding a linear search in the symbol table code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20479 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-06 05:42:36 +00:00
Jeff Cohen
e43dd1b8e7 Reformat comments to fix 80 columns.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20467 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-05 22:45:40 +00:00
Jeff Cohen
b21bf9a8d5 Reuse induction variables created for strength-reduced GEPs by other similar GEPs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20466 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-05 22:40:34 +00:00
Chris Lattner
7acff25f7f second argument to Value::setName is now gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20463 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-05 19:05:20 +00:00
Chris Lattner
8b9081081b Do not compute 1ULL << 64, which is undefined. This fixes Ptrdist/ks on the
sparc, and testcase Regression/Transforms/InstCombine/2005-03-04-ShiftOverflow.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20445 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-04 23:21:33 +00:00
Jeff Cohen
2f3c9b7562 Add support for not strength reducing GEPs where the element size is a small
power of two.  This emphatically includes the zeroeth power of two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20429 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-04 04:04:26 +00:00
Chris Lattner
5f792c2c53 Add an optional argument to lower to a specific constant value instead of
to a "sizeof" expression.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20414 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-03 01:03:43 +00:00
Jeff Cohen
0456e4a079 Fixed the following LSR bugs:
* Loop invariant code does not dominate the loop header, but rather
    the end of the loop preheader.

  * The base for a reduced GEP isn't a constant unless all of its
    operands (preceding the induction variable) are constant.

  * Allow induction variable elimination for the simple case after all.

Also made changes recommended by Chris for properly deleting
instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20383 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-01 03:46:11 +00:00
Jeff Cohen
14dc638081 Fix crash in LSR due to attempt to remove original induction variable. However,
for reasons explained in the comments, I also deactivated this code as it needs
more thought.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20367 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-28 00:08:56 +00:00
Jeff Cohen
5e1e5e13ff PHI nodes were incorrectly placed when more than one GEP is reduced in a loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20360 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 21:08:04 +00:00
Jeff Cohen
f465db6c6a First pass at improved Loop Strength Reduction. Still not yet ready for prime time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20358 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 19:37:07 +00:00
Chris Lattner
35c81b0b12 Teach globalopt how memset/cpy/move affect memory, to allow better optimization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20352 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 18:58:52 +00:00
Chris Lattner
da895d6337 Fix spelling, patch contributed by Gabor Greif!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20343 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-27 06:18:25 +00:00
Chris Lattner
be54dcc8a9 remove extraneous cast
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20334 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-26 18:33:28 +00:00
Chris Lattner
623369ac56 Implement Transforms/SimplifyCFG/switch_thread.ll
This does a simple form of "jump threading", which eliminates CFG edges that
are provably dead.  This triggers 90 times in the external tests, and
eliminating CFG edges is always always a good thing! :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20300 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-24 06:17:52 +00:00
Chris Lattner
1f21ef1511 make this more efficient. Scan up to 16 nodes, not the whole list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20289 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-23 16:53:04 +00:00
Chris Lattner
cfa2f8eef4 Remove use of bind_obj
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20276 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-22 23:22:58 +00:00
Chris Lattner
1a84bd38ef Do not mark obviously unreachable blocks live when processing PHI nodes,
and handle incomplete control dependences correctly.  This fixes:

Regression/Transforms/ADCE/dead-phi-edge.ll
  -> a missed optimization

Regression/Transforms/ADCE/dead-phi-edge.ll
  -> a compiler crash distilled from QT4


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20227 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-17 19:28:49 +00:00
Chris Lattner
8a7980b5ea Fix the second bug attached to PR504.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20181 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-14 20:11:45 +00:00
Chris Lattner
f6249261a9 Fix for testcase Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll
and PR504.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20129 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-12 03:26:49 +00:00
Alkis Evlogimenos
f64ea9d122 Localize globals if they are only used in main(). This replaces the
global with an alloca, which eventually gets promoted into a
register. This enables a lot of other optimizations later on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20109 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-10 18:36:30 +00:00
Alkis Evlogimenos
83874c9571 Fix crash on MallocInsts of unsized types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19988 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-02 04:43:37 +00:00
Chris Lattner
ac930048d6 API change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19959 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 01:23:49 +00:00
Chris Lattner
d514d8294d Adjust to changes in APIs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19958 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 01:23:31 +00:00
Chris Lattner
5a87447286 Hacks to make this ugly ugly code work with the new use lists.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19957 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 01:22:56 +00:00
Chris Lattner
fcfe33acda Implement InstCombine/cast.ll:test25, a case that occurs many times
in spec


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19953 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-31 05:51:45 +00:00
Chris Lattner
2f503e6c27 Implement the trivial cases in InstCombine/store.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19950 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-31 05:36:43 +00:00
Chris Lattner
f9527850e6 Implement Transforms/InstCombine/cast-load-gep.ll, which allows us to devirtualize
11 indirect calls in perlbmk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19947 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-31 04:50:46 +00:00
Chris Lattner
5551706b0f Adjust to changes in instruction interfaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19900 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-29 00:39:08 +00:00
Chris Lattner
667fdaef9f Switchinst takes a hint for the number of cases it will have.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19899 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-29 00:38:45 +00:00
Chris Lattner
378805969e switchinst ctor now takes a hint for the number of cases that it will have.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19898 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-29 00:38:26 +00:00
Chris Lattner
5598aa0328 Adjust Valuehandle to hold its operand directly in it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19897 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-29 00:37:36 +00:00
Chris Lattner
ad5fec12a0 * add some DEBUG statements
* Properly compile this:

struct a {};
int test() {
  struct a b[2];
  if (&b[0] != &b[1])
    abort ();
  return 0;
}

to 'return 0', not abort().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19875 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 19:32:01 +00:00
Alkis Evlogimenos
193904a663 Add a dependency to the trace library so that it gets pulled in
automatically.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19828 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-25 16:23:57 +00:00
Chris Lattner
ad1e302723 Get rid of a several dozen more and instructions in specint.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19786 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 20:26:55 +00:00
Chris Lattner
45f57b8ee3 Handle comparisons of gep instructions that have different typed indices
as long as they are the same size.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19734 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 23:06:49 +00:00
Chris Lattner
6fb5a4a5f8 Add two optimizations. The first folds (X+Y)-X -> Y
The second folds operations into selects, e.g. (select C, (X+Y), (Y+Z))
-> (Y+(select C, X, Z)

This occurs a few times across spec, e.g.

         select    add/sub
mesa:    83        0
povray:  5         2
gcc      4         2
parser   0         22
perlbmk  13        30
twolf    0         3


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19706 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 21:50:18 +00:00
Chris Lattner
7d719c3cd8 Fix 'raise' to work with packed types. Patch by Morten Ofstad.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19693 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 16:16:35 +00:00
Chris Lattner
a3fd1c569c Delete PHI nodes that are not dead but are locked in a cycle of single
useness.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19629 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 05:10:15 +00:00
Chris Lattner
b352fa5853 Move code out of indentation one level to make it easier to read.
Disable the xform for < > cases.  It turns out that the following is being
miscompiled:

bool %test(sbyte %S) {
        %T = cast sbyte %S to uint
        %V = setgt uint %T, 255
        ret bool %V
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19628 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-17 03:20:02 +00:00
Chris Lattner
906ab50acf Fix some bugs in an xform added yesterday. This fixes Prolangs-C/allroots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19553 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-14 17:35:12 +00:00
Chris Lattner
6f7f02fdec Fix a compile crash on spiff
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19552 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-14 17:17:59 +00:00
Chris Lattner
4401c9cabe if two gep comparisons only differ by one index, compare that index directly.
This allows us to better optimize begin() -> end() comparisons in common cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19542 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-14 00:20:05 +00:00
Chris Lattner
0b84c80c08 Do not overrun iterators. This fixes a 176.gcc crash
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19541 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 23:26:48 +00:00
Chris Lattner
87875dac89 Turn select C, (X+Y), (X-Y) --> (X+(select C, Y, (-Y))). This occurs in
the 'sim' program and probably elsewhere.  In sim, it comes up for cases
like this:

#define round(x) ((x)>0.0 ? (x)+0.5 : (x)-0.5)
double G;
void T(double X) { G = round(X); }

(it uses the round macro a lot).  This changes the LLVM code from:

        %tmp.1 = setgt double %X, 0.000000e+00          ; <bool> [#uses=1]
        %tmp.4 = add double %X, 5.000000e-01            ; <double> [#uses=1]
        %tmp.6 = sub double %X, 5.000000e-01            ; <double> [#uses=1]
        %mem_tmp.0 = select bool %tmp.1, double %tmp.4, double %tmp.6
        store double %mem_tmp.0, double* %G

to:

        %tmp.1 = setgt double %X, 0.000000e+00          ; <bool> [#uses=1]
        %mem_tmp.0.p = select bool %tmp.1, double 5.000000e-01, double -5.000000e-01
        %mem_tmp.0 = add double %mem_tmp.0.p, %X
        store double %mem_tmp.0, double* %G
        ret void


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19537 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 22:52:24 +00:00
Chris Lattner
e9d782b7be Implement an optimization for == and != comparisons like this:
_Bool test2(int X, int Y) {
  return &arr[X][Y] == arr;
}

instead of generating this:

bool %test2(int %X, int %Y) {
        %tmp.3.idx = mul int %X, 160            ; <int> [#uses=1]
        %tmp.3.idx1 = shl int %Y, ubyte 2               ; <int> [#uses=1]
        %tmp.3.offs2 = sub int 0, %tmp.3.idx            ; <int> [#uses=1]
        %tmp.7 = seteq int %tmp.3.idx1, %tmp.3.offs2            ; <bool> [#uses=1]
        ret bool %tmp.7
}


generate this:

bool %test2(int %X, int %Y) {
        seteq int %X, 0         ; <bool>:0 [#uses=1]
        seteq int %Y, 0         ; <bool>:1 [#uses=1]
        %tmp.7 = and bool %0, %1                ; <bool> [#uses=1]
        ret bool %tmp.7
}

This idiom occurs in C++ programs when iterating from begin() to end(),
in a vector or array.  For example, we now compile this:

void test(int X, int Y) {
  for (int *i = arr; i != arr+100; ++i)
    foo(*i);
}

to this:

no_exit:                ; preds = %entry, %no_exit
	...
        %exitcond = seteq uint %indvar.next, 100                ; <bool> [#uses=1]
        br bool %exitcond, label %return, label %no_exit



instead of this:

no_exit:                ; preds = %entry, %no_exit
	...
        %inc5 = getelementptr [100 x [40 x int]]* %arr, int 0, int 0, int %inc.rec              ; <int*> [#uses=1]
        %tmp.8 = seteq int* %inc5, getelementptr ([100 x [40 x int]]* %arr, int 0, int 100, int 0)              ; <bool> [#uses=1]
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=1]
        br bool %tmp.8, label %return, label %no_exit


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19536 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 22:25:21 +00:00
Chris Lattner
5bdf04cc8e Fix some bugs in code I didn't mean to check in.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19534 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 20:40:58 +00:00
Chris Lattner
574da9ba0b Fix a crash compiling 129.compress
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19533 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-13 20:14:25 +00:00
Reid Spencer
99f997d2c1 Add the LOADABLE_MODULE=1 directive to indicate that this shared library is
intended to be a dlopenable module and not a "plain" shared library.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19456 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-11 04:33:32 +00:00
Jeff Cohen
ecc1cef8bf Apply feedback from Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19432 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-10 04:23:32 +00:00
Chris Lattner
22bc934720 Fix VS warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19383 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:48:40 +00:00
Chris Lattner
4d0801b243 Fix VS warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19382 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:45:31 +00:00
Chris Lattner
652f3cf76f Fix uint64_t -> unsigned VS warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19381 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:42:22 +00:00
Chris Lattner
d4bc564531 Silence VS warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19380 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:37:20 +00:00
Chris Lattner
2cc34627bb Silence warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19379 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 19:34:41 +00:00
Jeff Cohen
bf65268def Add more missing createXxxPass functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19370 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-08 17:21:40 +00:00
Misha Brukman
60766f7d41 Convert tabs to spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19320 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-07 07:05:34 +00:00
Jeff Cohen
d9ed8c8880 Add missing createXxxPass functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19319 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-07 06:57:28 +00:00
Jeff Cohen
30becbda10 Add missing include
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19315 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-07 05:42:13 +00:00