Commit Graph

1309 Commits

Author SHA1 Message Date
Chris Lattner
548f47efb0 Fix a bug in yesterdays checkins which broke siod. siod is a great testcase! :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12659 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 16:02:41 +00:00
Chris Lattner
15a76c0b35 Fix InstCombine/2004-04-04-InstCombineReplaceAllUsesWith.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12658 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-05 02:10:19 +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
40bf8b48cd Rewrite the indvars pass to use the ScalarEvolution analysis.
This also implements some new features for the indvars pass, including
linear function test replacement, exit value substitution, and it works with
a much more general class of induction variables and loops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12620 91177308-0d34-0410-b5e6-96231b3b80d8
2004-04-02 20:24:31 +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
Brian Gaeke
87fa610ee0 Start cleaning up this pass so that I can debug it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12548 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-30 19:53:46 +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
c32b30a429 Implement select.ll:test[3-6]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12544 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-30 19:37:13 +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
4df1b8aa26 X % -1 == X % 1 == 0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12520 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-26 16:11:24 +00:00
Chris Lattner
ebd985cb87 Two changes:
#1 is to unconditionally strip constantpointerrefs out of
instruction operands where they are absolutely pointless and inhibit
optimization.  GRRR!

#2 is to implement InstCombine/getelementptr_const.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12519 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-25 22:59:29 +00:00
Chris Lattner
7c881dffc9 Teach the optimizer to delete zero sized alloca's (but not mallocs!)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12507 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-19 06:08: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
f6e43bc796 Add statistics to the loop extractor. The loop extractor has successfully
extracted all 63 loops for Olden/bh without crashing and without
miscompiling the program!!!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12491 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:46:10 +00:00
Chris Lattner
fdded9f95a Fix problem with PHI nodes having multiple predecessors from different
exit nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12490 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 05:43:18 +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
369287bab5 The code extractor needs dominator info. Provide it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12483 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-18 03:48:06 +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
e911979650 Be more accurate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12464 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-17 01:59:27 +00:00
Chris Lattner
50eafbc828 Fix bug in previous checkin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12458 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:36:49 +00:00
Chris Lattner
24ad00db5a Okay, so there is no reasonable way for tail duplication to update SSA form,
as it is making effectively arbitrary modifications to the CFG and we don't
have a domset/domfrontier implementations that can handle the dynamic updates.
Instead of having a bunch of code that doesn't actually work in practice,
just demote any potentially tricky values to the stack (causing the problem
to go away entirely).  Later invocations of mem2reg will rebuild SSA for us.

This fixes all of the major performance regressions with tail duplication
from LLVM 1.1.  For example, this loop:

---
int popcount(int x) {
  int result = 0;
  while (x != 0) {
    result = result + (x & 0x1);
    x = x >> 1;
  }
  return result;
}
---
Used to be compiled into:

int %popcount(int %X) {
entry:
	br label %loopentry

loopentry:		; preds = %entry, %no_exit
	%x.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]		; <int> [#uses=3]
	%result.1.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]		; <int> [#uses=2]
	%tmp.1 = seteq int %x.0, 0		; <bool> [#uses=1]
	br bool %tmp.1, label %loopexit, label %no_exit

no_exit:		; preds = %loopentry
	%tmp.4 = and int %x.0, 1		; <int> [#uses=1]
	%tmp.6 = add int %tmp.4, %result.1.0		; <int> [#uses=1]
	%tmp.9 = shr int %x.0, ubyte 1		; <int> [#uses=1]
	br label %loopentry

loopexit:		; preds = %loopentry
	ret int %result.1.0
}

And is now compiled into:

int %popcount(int %X) {
entry:
        br label %no_exit

no_exit:                ; preds = %entry, %no_exit
        %x.0.0 = phi int [ %X, %entry ], [ %tmp.9, %no_exit ]          ; <int> [#uses=2]
        %result.1.0.0 = phi int [ 0, %entry ], [ %tmp.6, %no_exit ]             ; <int> [#uses=1]
        %tmp.4 = and int %x.0.0, 1              ; <int> [#uses=1]
        %tmp.6 = add int %tmp.4, %result.1.0.0          ; <int> [#uses=2]
        %tmp.9 = shr int %x.0.0, ubyte 1                ; <int> [#uses=2]
        %tmp.1 = seteq int %tmp.9, 0            ; <bool> [#uses=1]
        br bool %tmp.1, label %loopexit, label %no_exit

loopexit:               ; preds = %no_exit
        ret int %tmp.6
}


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12457 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 23:29:09 +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
91408eba18 Punt if we see gigantic PHI nodes. This improves a huge interpreter loop
testcase from 32.5s in -raise to take .3s


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12443 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:52:53 +00:00
Chris Lattner
a2f652d420 Do not try to optimize PHI nodes with incredibly high degree. This reduces SCCP
time from 615s to 1.49s on a large testcase that has a gigantic switch statement
that all of the blocks in the function go to (an intepreter).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12442 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-16 19:49:59 +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
6dd196f762 Restore old inlining heuristic. As the comment indicates, this is a nasty
horrible hack.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12423 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 06:38:14 +00:00
Chris Lattner
46234fd97f Add counters for the number of calls elimianted
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12420 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 05:46:59 +00:00
Chris Lattner
118dd0ce3d Implement LICM of calls in simple cases. This is sufficient to move around
sin/cos/strlen calls and stuff.  This implements:
  LICM/call_sink_pure_function.ll
  LICM/call_sink_const_function.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12415 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 04:11:30 +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
5156c39d64 Fix several bugs in the loop extractor. In particular, subloops were never
extracted, and a function that contained a single top-level loop never had
the loop extracted, regardless of how much non-loop code there was.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12403 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-15 00:02:02 +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
Chris Lattner
12f390e9c0 Simplify code a bit, and fix bug CodeExtractor/2004-03-14-NoSwitchSupport.ll
This also implements a two minor improvements:
  * Don't insert live-out stores IN the region, insert them on the code path
    that exits the region
  * If the region is exited to the same block from multiple paths, share the
    switch statement entry, live-out store code, and the basic block.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12401 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 23:05:49 +00:00
Chris Lattner
0e06674287 Simplify the code a bit by making the collection of basic blocks to extract
a member of the class.  While we're at it, turn the collection into a set
instead of a vector to improve efficiency and make queries simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12400 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 22:34:55 +00:00
Chris Lattner
41bc0b069c Split into two passes. Now there is the general loop extractor, usable on
the command line, and the single loop extractor, usable by bugpoint


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12390 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 20:01:36 +00:00
Chris Lattner
97836fad2c Passes don't print stuff!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12385 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:17:53 +00:00
Chris Lattner
bf9eaddfb0 Do not create empty basic blocks when the lowerswitch pass expects blocks to
be non-empty!  This fixes LowerSwitch/2004-03-13-SwitchIsDefaultCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12384 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:14:31 +00:00
Chris Lattner
bb41156c0c Minor random cleanups
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12382 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:01:47 +00:00
Chris Lattner
16d0eb0468 FunctionPass's should not define their own 'run' method.
Require 'simplified' loops, not just raw natural loops.  This fixes
CodeExtractor/2004-03-13-LoopExtractorCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12381 91177308-0d34-0410-b5e6-96231b3b80d8
2004-03-14 04:01:06 +00:00