Commit Graph

386 Commits

Author SHA1 Message Date
Brian Gaeke
c58a7f4b3c Add CloneTraceInto(), which is based on (and has mostly the same
effects as) CloneFunctionInto().


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13601 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-19 09:08:14 +00:00
Brian Gaeke
6129af3fb1 Move RemapInstruction() to ValueMapper, so that it can be shared with
CloneTrace, and because it is primarily an operation on ValueMaps.  It
is now a global (non-static) function which can be pulled in using
ValueMapper.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13600 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-19 09:08:12 +00:00
Chris Lattner
587992721c Do not pass in the same argument to the extracted function more than once, and
give the extracted function a more useful name than just foo_code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13493 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 16:26:18 +00:00
Chris Lattner
d99e1d3afb Implement support for code extracting basic blocks that have a return
instruction in them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 16:07:41 +00:00
Chris Lattner
e746ad512e Implement splitting of PHI nodes, allowing block extraction of BB's that have
PHI node entries from multiple outside-the-region blocks.  This also fixes
extraction of the entry block in a function.  Yaay.

This has successfully block extracted all (but one) block from the score_move
function in obsequi (out of 33).  Hrm, I wonder which block the bug is in.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13489 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 15:29:13 +00:00
Chris Lattner
bf749367cb * Pull some code out into the definedInRegion/definedInCaller methods
* Add a stub for the severSplitPHINodes which will allow us to bbextract
  bb's with PHI nodes in them soon.
* Remove unused arguments from findInputsOutputs
* Dramatically simplify the code in findInputsOutputs.  In particular,
  nothing really cares whether or not a PHI node is using something.
* Move moveCodeToFunction to after emitCallAndSwitchStatement as that's the
  order they get called.
* Fix a bug where we would code extract a region that included a call to
  vastart.  Like 'alloca', calls to vastart must stay in the function that
  they are defined in.
* Add some comments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13482 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 06:01:40 +00:00
Chris Lattner
346be7f5bc Generate substantially better code when there are a limited number of exits
from the extracted region.  If the return has 0 or 1 exit blocks, the new
function returns void.  If it has 2 exits, it returns bool, otherwise it
returns a ushort as before.

This allows us to use a conditional branch instruction when there are two
exit blocks, as often happens during block extraction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13481 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 04:14:24 +00:00
Chris Lattner
5b01e298ed Two minor improvements:
1. Get rid of the silly abort block.  When doing bb extraction, we get one
     abort block for every block extracted, which is kinda annoying.
  2. If the switch ends up having a single destination, turn it into an
     unconditional branch.

I would like to add support for conditional branches, but to do this we will
want to have the function return a bool instead of a ushort.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13478 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-12 03:22:33 +00:00
Chris Lattner
bdcc0b8c55 Do not clone arbitrary condition instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13316 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 05:19:36 +00:00
Chris Lattner
12fe2b1b82 Do not infinitely "unroll" single BB loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13315 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 05:02:03 +00:00
Chris Lattner
a1f79fb08b Dont' merge terminators that are needed to select PHI node values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13312 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-02 01:00:44 +00:00
Chris Lattner
e67fa05036 Implement SimplifyCFG/branch-cond-merge.ll
Turning "if (A < B && B < C)" into "if (A < B & B < C)"


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13311 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 23:35:43 +00:00
Chris Lattner
951fdb9764 Fix my missing parens
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13307 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 22:41:51 +00:00
Chris Lattner
92da2c2053 Implement SimplifyCFG/branch-cond-prop.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13306 91177308-0d34-0410-b5e6-96231b3b80d8
2004-05-01 22:36:37 +00:00
Misha Brukman
22108fac63 * Allow aggregating extracted function arguments (controlled by flag)
* Commandline option (for now) controls that flag that is passed in


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13141 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-23 23:54:17 +00:00
Alkis Evlogimenos
09233fb86e Include cerrno (gcc-3.4 fix)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13091 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-21 16:11:40 +00:00
Chris Lattner
59fb87d469 Correct rewriting of exit blocks after my last patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13048 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:27:10 +00:00
Chris Lattner
f1ab4b4eac Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand.  This makes updating
loop information MUCH easier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13045 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-18 22:14:10 +00:00
Chris Lattner
f5b9eb37a9 Add support for evaluation of exp/log/log10/pow
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13011 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 22:35:33 +00:00
Brian Gaeke
c598517c24 Include <cmath> for compatibility with gcc 3.0.x (the system compiler on
Debian.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12986 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 15:57:32 +00:00
Chris Lattner
cd01ae5c70 Fix Inline/2004-04-15-InlineDeletesCall.ll
Basically we were using SimplifyCFG as a huge sledgehammer for a simple
optimization.  Because simplifycfg does so many things, we can't use it
for this purpose.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12977 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-16 05:17:59 +00:00
Chris Lattner
25b8390bf2 Add a simple call constant propagation interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12919 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 19:28:52 +00:00
Chris Lattner
4b66242c54 Fix LoopSimplify/2004-04-13-LoopSimplifyUpdateDomFrontier.ll
LoopSimplify was not updating dominator frontiers correctly in some cases.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12890 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 16:23:25 +00:00
Chris Lattner
1f62f82b05 Refactor code a bit to make it simpler and eliminate the goto
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12888 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 15:21:18 +00:00
Chris Lattner
529b28da45 This patch addresses PR35: Loop simplify should reconstruct nested loops.
This is fairly straight-forward, but was a real nightmare to get just
perfect.  aarg.  :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12884 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-13 05:05:33 +00:00
Chris Lattner
570751c2a7 Fold code like:
if (C)
    V1 |= V2;

into:
  Vx = V1 | V2;
  V1 = select C, V1, Vx

when the expression can be evaluated unconditionally and is *cheap* to
execute.  This limited form of if conversion is quite handy in lots of cases.
For example, it turns this testcase into straight-line code:

int in0 ; int in1 ; int in2 ; int in3 ;
int in4 ; int in5 ; int in6 ; int in7 ;
int in8 ; int in9 ; int in10; int in11;
int in12; int in13; int in14; int in15;
long output;

void mux(void) {
  output =
      (in0   ?  0x00000001 : 0) | (in1   ?  0x00000002 : 0) |
      (in2   ?  0x00000004 : 0) | (in3   ?  0x00000008 : 0) |
      (in4   ?  0x00000010 : 0) | (in5   ?  0x00000020 : 0) |
      (in6   ?  0x00000040 : 0) | (in7   ?  0x00000080 : 0) |
      (in8   ?  0x00000100 : 0) | (in9   ?  0x00000200 : 0) |
      (in10  ?  0x00000400 : 0) | (in11  ?  0x00000800 : 0) |
      (in12  ?  0x00001000 : 0) | (in13  ?  0x00002000 : 0) |
      (in14  ?  0x00004000 : 0) | (in15  ?  0x00008000 : 0) ;
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12798 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-09 22:50:22 +00:00
Chris Lattner
8ba725b456 Implement ScalarRepl/select_promote.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12779 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-08 19:59:34 +00:00
Chris Lattner
28977af72a Support getelementptr instructions which use uint's to index into structure
types and can have arbitrary 32- and 64-bit integer types indexing into
sequential types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12653 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 01:30:19 +00:00
Chris Lattner
7aa773bc07 Fix the obvious bug in my previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12618 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-02 18:15:10 +00:00
Chris Lattner
147af6b75f Implement Transforms/SimplifyCFG/return-merge.ll
This actually causes us to turn code like:

  return C ? A : B;

into a select instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12617 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-02 18:13:43 +00:00
Chris Lattner
c68bace452 Fix PR310 and TailDup/2004-04-01-DemoteRegToStack.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12597 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-01 20:28:45 +00:00
Chris Lattner
4edf6c043e Remove some assertions that are now bogus with the last patch I put in
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12595 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-01 19:21:46 +00:00
Chris Lattner
4f303bd4a5 Fix PR306: Loop simplify incorrectly updates dominator information
Testcase: LoopSimplify/2004-04-01-IncorrectDomUpdate.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12592 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-01 19:06:07 +00:00
Chris Lattner
0e28eca4bc Add warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12573 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-31 22:00:30 +00:00
Chris Lattner
1438102576 Fix linking of constant expr casts due to type resolution changes. With
this and the other patches 253.perlbmk links again.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12565 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-31 02:58:28 +00:00
Chris Lattner
552112f2f8 Now that all the code generators support the select instruction, and the instcombine
pass can eliminate many nasty cases of them, start generating them in the optimizers


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12545 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-30 19:44:05 +00:00
Chris Lattner
18bdbc3dda Add a simple select instruction lowering pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12540 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-30 18:41:10 +00:00
Chris Lattner
aa7ab53b99 Fix bug: CodeExtractor/2004-03-17-MissedLiveIns.ll
With this fix we now successfully extract all 149 loops from 256.bzip2 without
crashing or miscompiling the program!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12493 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:56:32 +00:00
Chris Lattner
d07f899691 Fix CodeExtractor/2004-03-17-UpdatePHIsOutsideRegion.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12489 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:38:31 +00:00
Chris Lattner
5cc8ca6420 Seriously simplify and correct the PHI node handling code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12487 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:28:49 +00:00
Chris Lattner
04229c192b Fix CodeExtractor/2004-03-17-OutputMismatch.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12486 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 04:12:05 +00:00
Chris Lattner
b5c1dbf503 Fix several bugs in the extractor:
1. Names were not put on the new arguments created (ok, this just helps sanity :)
2. Fix outgoing pointer values
3. Do not insert stores for values that had not been computed
4. Fix some wierd problems with the outset calculation

This fixes CodeExtractor/2004-03-14-DominanceProblem.ll, making the extractor
work on at least one simple case!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12484 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:49:40 +00:00
Chris Lattner
33e197b777 Prune #includes, moving the module interface to the front. Note that this
exposed the fact that the header was not self-contained.  There is a reason
we do things :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12481 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:15:29 +00:00
Chris Lattner
7acd1ccb8a Fix compilation of mesa, which I broke earlier today
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12465 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-17 02:02:47 +00:00
Chris Lattner
c1a0623e86 This code was both incredibly complex and incredibly broken. Fix it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12456 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:23:11 +00:00
Chris Lattner
4bebf08d15 Do not copy gigantic switch instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12441 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:45:22 +00:00
Chris Lattner
85ebd541fa Fix a regression from this patch:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040308/013095.html

Basically, this patch only updated the immediate dominatees of the header node
to tell them that the preheader also dominated them.  In practice, ALL
dominatees of the header node are also dominated by the preheader.

This fixes: LoopSimplify/2004-03-15-IncorrectDomUpdate.
and PR293


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12434 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 06:00:15 +00:00
Chris Lattner
15d443b566 Mostly cosmetic improvements. Do fix the bug where a global value was considered an input.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12406 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 01:26:44 +00:00
Chris Lattner
0de632bfae Assert that input blocks meet the invariants we expect
Simplify the input/output finder.  All elements of a basic block are
instructions.  Any used arguments are also inputs.  An instruction can only
be used by another instruction.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12405 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 01:18:23 +00:00
Chris Lattner
65826bf435 No correctness fixes here, just minor qoi fixes:
* Don't insert a branch to the switch instruction after the call, just
  make it a single block.
* Insert the new alloca instructions in the entry block of the original
  function instead of having them execute dynamically
* Don't make the default edge of the switch instruction go back to the switch.
  The loop extractor shouldn't create new loops!
* Give meaningful names to the alloca slots and the reload instructions
* Some minor code simplifications


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12402 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 23:43:24 +00:00