Commit Graph

146 Commits

Author SHA1 Message Date
Chris Lattner 700b873130 Detemplatize the Statistic class. The only type it is instantiated with
is 'unsigned'.

llvm-svn: 32279
2006-12-06 17:46:33 +00:00
Jeff Cohen cc08c83186 Unbreak VC++ build.
llvm-svn: 32113
2006-12-02 02:22:01 +00:00
Evan Cheng 67fc141db5 Match TargetInstrInfo changes.
llvm-svn: 32098
2006-12-01 21:52:58 +00:00
Bill Wendling 5c3966aa68 Converted to using llvm streams instead of <iostream>s
llvm-svn: 31992
2006-11-29 00:39:47 +00:00
Bill Wendling d811cc6818 Don't recompute getNumOperands for each iteration.
llvm-svn: 31783
2006-11-16 07:35:18 +00:00
Bill Wendling c7969fd1e7 Added a new method "CreateNewLiveInterval" which, given a list of
LiveRanges, creates a new LiveInterval from them. The LiveRanges should
have existed already in another LiveInterval, but removed.

llvm-svn: 31780
2006-11-16 02:41:50 +00:00
Evan Cheng 12ea213de9 A register def can be partially dead when the whole register has use(s) but a subreg does not.
llvm-svn: 31760
2006-11-15 20:54:11 +00:00
Evan Cheng 8c9c6d71ed Add implicit def / use operands to MachineInstr.
llvm-svn: 31633
2006-11-10 08:43:01 +00:00
Jim Laskey 61feeb90f9 Remove redundant <cmath>.
llvm-svn: 31561
2006-11-08 19:16:44 +00:00
Chris Lattner b18177bfab Enable improved spilling costs by default. This speeds up viterbi on x86
by 40%, FreeBench/fourinarow by 20%, and many other programs 10-25%.

On PPC, this speeds up fourinarow by 18%, and probably other things as well.

llvm-svn: 31504
2006-11-07 18:04:58 +00:00
Jim Laskey 6a9342166b Use correct value for float HUGH_VAL.
llvm-svn: 31500
2006-11-07 12:25:45 +00:00
Chris Lattner 01d039cc44 Add a new llcbeta option. This speeds up viterbi from 12.34 to 8.76s on
X86.  If happy, I'll enable this by default.

llvm-svn: 31493
2006-11-07 07:18:40 +00:00
Evan Cheng 299022d514 Proper check for two-addressness.
llvm-svn: 31408
2006-11-03 03:04:46 +00:00
Reid Spencer de46e48420 For PR786:
Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting
fall out by removing unused variables. Remaining warnings have to do with
unused functions (I didn't want to delete code without review) and unused
variables in generated code. Maintainers should clean up the remaining
issues when they see them. All changes pass DejaGnu tests and Olden.

llvm-svn: 31380
2006-11-02 20:25:50 +00:00
Chris Lattner 8fb3d445f5 Keep track of the start of MBB's in a separate map from instructions. This
is faster and is needed for future improvements.

llvm-svn: 30383
2006-09-15 03:57:23 +00:00
Chris Lattner 13a5dcddce Fix a long-standing wart in the code generator: two-address instruction lowering
actually *removes* one of the operands, instead of just assigning both operands
the same register.  This make reasoning about instructions unnecessarily complex,
because you need to know if you are before or after register allocation to match
up operand #'s with the target description file.

Changing this also gets rid of a bunch of hacky code in various places.

This patch also includes changes to fold loads into cmp/test instructions in
the X86 backend, along with a significant simplification to the X86 spill
folding code.

llvm-svn: 30108
2006-09-05 02:12:02 +00:00
Chris Lattner 1eed04d1fb Correct fix for a crasher on functions with live in values
llvm-svn: 30099
2006-09-04 18:27:40 +00:00
Chris Lattner bff0b5969f Hack around a regression I introduced yesterday
llvm-svn: 30098
2006-09-04 18:20:15 +00:00
Chris Lattner 8584e940b8 Avoid beating on the mi2i map when we know the answer already.
llvm-svn: 30066
2006-09-03 08:07:11 +00:00
Chris Lattner 774785a79d minor speedup
llvm-svn: 30065
2006-09-03 07:53:50 +00:00
Chris Lattner 75742e532a Iteration is required for some cases, even if they don't occur in crafty.
Restore it, which re-fixes X86/2006-08-21-ExtraMovInst.ll

llvm-svn: 30050
2006-09-02 05:32:53 +00:00
Chris Lattner 5a56d30906 When joining two intervals where the RHS is really simple, use a light-weight
method for joining the live ranges instead of the fully-general one.

llvm-svn: 30049
2006-09-02 05:26:59 +00:00
Chris Lattner 93c067dc2d Pull some code out of a hot recursive function because the common case doesn't
need recursion.

llvm-svn: 30015
2006-09-01 07:00:23 +00:00
Chris Lattner 3eac2c87aa Reserve space in the ValueNumberInfo vector. This speeds up live interval
analysis 16% on crafty.

Wrap long lines.

llvm-svn: 30012
2006-09-01 06:10:18 +00:00
Chris Lattner f765351978 Iterative coallescing doesn't buy us anything (we get identical results on
crafty with and without it).  Removing it speeds up live intervals 6%.

llvm-svn: 30010
2006-09-01 04:02:42 +00:00
Chris Lattner a700a19d04 Add a special case that speeds up coallescing a bit, but not enough.
llvm-svn: 29996
2006-08-31 06:48:26 +00:00
Chris Lattner 78cca7243c Delete copies as they are coallesced instead of waiting until the end.
llvm-svn: 29995
2006-08-31 05:58:59 +00:00
Chris Lattner aa36808fd3 avoid calling the virtual isMoveInstr method endlessly by caching its results.
llvm-svn: 29994
2006-08-31 05:54:43 +00:00
Chris Lattner cb74860cce Fix a compiler crash bootstrapping llvm-gcc.
llvm-svn: 29989
2006-08-30 23:02:29 +00:00
Chris Lattner 34434e97c9 Teach the coallescer to coallesce live intervals joined by an arbitrary
number of copies, potentially defining live ranges that appear to have
differing value numbers that become identical when coallsced.  Among other
things, this fixes CodeGen/X86/shift-coalesce.ll and PR687.

llvm-svn: 29968
2006-08-29 23:18:15 +00:00
Chris Lattner 3c9b2420df Eliminate RegisterAnalysis. RegisterPass now does all that is necessary.
llvm-svn: 29921
2006-08-27 22:30:17 +00:00
Chris Lattner 2c3683a901 typo fix
llvm-svn: 29910
2006-08-27 12:47:48 +00:00
Chris Lattner 122f2bcdc2 Simplifications to liveinterval analysis, no functionality change.
llvm-svn: 29896
2006-08-26 01:28:16 +00:00
Chris Lattner f4f0b1995c Completely change the way that joining with physregs is implemented. This
paves the way for future changes, increases coallescing opportunities (in
theory, not witnessed in practice), and eliminates the really expensive
LiveIntervals::overlapsAliases method.

llvm-svn: 29890
2006-08-25 23:41:24 +00:00
Chris Lattner bdf121060c Take advantage of the recent improvements to the liveintervals set (tracking
instructions which define each value#) to simplify and improve the coallescer.
In particular, this patch:

1. Implements iterative coallescing.
2. Reverts an unsafe hack from handlePhysRegDef, superceeding it with a
   better solution.
3. Implements PR865, "coallescing" away the second copy in code like:

   A = B
   ...
   B = A

This also includes changes to symbolically print registers in intervals
when possible.

llvm-svn: 29862
2006-08-24 22:43:55 +00:00
Chris Lattner 2e9f1bc056 Improve the LiveInterval class to keep track of which machine instruction
defines each value# tracked by the interval.  This will be used to improve
coallescing.

llvm-svn: 29830
2006-08-22 18:19:46 +00:00
Chris Lattner 1d77a0ff88 Print physreg names symbolically in dumps
llvm-svn: 29805
2006-08-21 23:03:54 +00:00
Chris Lattner 213159a6ee Print debug info as:
*** Register mapping ***
  reg 1024 -> %reg1028
  reg 1026 -> EAX
  reg 1027 -> %reg1028

instead of:

*** Register mapping ***
  reg 1024 -> reg 1028
  reg 1026 -> reg 15
  reg 1027 -> reg 1028

llvm-svn: 29803
2006-08-21 22:56:29 +00:00
Jim Laskey 4b49c23571 Eliminate data relocations by using NULL instead of global empty list.
llvm-svn: 29250
2006-07-21 21:15:20 +00:00
Andrew Lenharth c496b418b5 Reduce number of exported symbols
llvm-svn: 29220
2006-07-20 17:28:38 +00:00
Chris Lattner aa2372562e Patches to make the LLVM sources more -pedantic clean. Patch provided
by Anton Korobeynikov!  This is a step towards closing PR786.

llvm-svn: 28447
2006-05-24 17:04:05 +00:00
Evan Cheng 6a6886185b Backing out fix for PR770. Need to re-apply it after live range splitting is possible
llvm-svn: 28236
2006-05-12 06:06:34 +00:00
Evan Cheng 47926aff96 Set weight of zero length intervals to infinite to prevent them from being
spilled.

llvm-svn: 28220
2006-05-11 07:29:24 +00:00
Evan Cheng ae45020720 PR 770 - permit coallescing of registers in subset register classes.
llvm-svn: 28197
2006-05-09 06:37:48 +00:00
Chris Lattner 10d6341618 Move some methods out of MachineInstr into MachineOperand
llvm-svn: 28102
2006-05-04 17:52:23 +00:00
Chris Lattner 4dee67c2cd Remove previous patch, which wasn't quite right.
llvm-svn: 28039
2006-05-01 21:16:03 +00:00
Evan Cheng f71f0f2e0b Local spiller kills a store if the folded restore is turned into a copy.
But this is incorrect if the spilled value live range extends beyond the
current BB.
It is currently controlled by a temporary option -spiller-check-liveout.

llvm-svn: 28024
2006-04-30 08:41:47 +00:00
Chris Lattner de02d7727f Add explicit #includes of <iostream>
llvm-svn: 25515
2006-01-22 23:41:00 +00:00
Chris Lattner b05fce676f Minor cleanup, no functionality change for current targets
llvm-svn: 25173
2006-01-10 05:41:59 +00:00
Chris Lattner b723c33614 Change a variable from being an iterator to a raw MachineInstr*, to make
GDB use tolerable

llvm-svn: 25064
2006-01-03 07:41:37 +00:00
Chris Lattner 3c7974aade Fix some spello's pointed out by Gabor Greif
llvm-svn: 24019
2005-10-26 18:41:41 +00:00
Chris Lattner e95b5745c0 Make the coallescer a bit smarter, allowing it to join more live ranges.
For example, we can now join things like [0-30:0)[31-40:1)[52-59:2)
with [40:60:0) if the 52-59 range is defined by a copy from the 40-60 range.
The resultant range ends up being [0-30:0)[31-60:1).

This fires a lot through-out the test suite (e.g. shrinking bc from
19492 -> 18509 machineinstrs) though most gains are smaller (e.g. about
50 copies eliminated from crafty).

llvm-svn: 23866
2005-10-21 06:49:50 +00:00
Chris Lattner b1f8982ff0 Expose the LiveInterval interfaces as public headers.
llvm-svn: 23400
2005-09-21 04:19:09 +00:00
Chris Lattner ce3662f2a2 remove debugging code *slaps head*
llvm-svn: 23294
2005-09-09 19:19:20 +00:00
Chris Lattner c9053083eb When spilling a live range that is used multiple times by one instruction,
only add a reload live range once for the instruction.  This is one step
towards fixing a regalloc pessimization that Nate notice, but is later undone
by the spiller (so no code is changed).

llvm-svn: 23293
2005-09-09 19:17:47 +00:00
Chris Lattner 5d16dbd5bb Fix a bug that Tzu-Chien Chiu noticed: live interval analysis does NOT
preserve livevar

llvm-svn: 23259
2005-09-07 17:34:39 +00:00
Chris Lattner 7138f91424 Teach live intervals to not crash on dead livein regs
llvm-svn: 23206
2005-09-02 00:20:32 +00:00
Chris Lattner 774158239b Simplify this code by using higher-level LiveVariables methods
llvm-svn: 22989
2005-08-23 22:51:41 +00:00
Chris Lattner 96cbfbbeaf Fix debug info to not print out recently freed memory.
llvm-svn: 22529
2005-07-27 23:11:25 +00:00
Chris Lattner 9937713252 Print symbolic register names in debug dumps
llvm-svn: 22528
2005-07-27 23:03:38 +00:00
Chris Lattner c08d786ba5 Print the symbolic register name in a register allocator debug dump.
llvm-svn: 22002
2005-05-14 05:34:15 +00:00
Chris Lattner 91caf1d039 allow a virtual register to be associated with live-in values.
llvm-svn: 21927
2005-05-13 07:08:07 +00:00
Misha Brukman 835702a094 Remove trailing whitespace
llvm-svn: 21420
2005-04-21 22:36:52 +00:00
Chris Lattner 1a44855f8f there is no need to remove this instruction, linscan does it already as it
removes noop moves.

llvm-svn: 21183
2005-04-09 16:24:20 +00:00
Chris Lattner 0b1681bce1 Adjust live intervals to support a livein set
llvm-svn: 21182
2005-04-09 16:17:50 +00:00
Chris Lattner 6f6ecad995 I didn't mean to check this in. :(
llvm-svn: 20555
2005-03-10 20:59:51 +00:00
Chris Lattner 76aa8e071b Allow the live interval analysis pass to be a bit more aggressive about
numbering values in live ranges for physical registers.

The alpha backend currently generates code that looks like this:

  vreg = preg
...
  preg = vreg
  use preg
...
  preg = vreg
  use preg

etc.  Because vreg contains the value of preg coming in, each of the
copies back into preg contain that initial value as well.

In the case of the Alpha, this allows this testcase:

void "foo"(int %blah) {
        store int 5, int *%MyVar
        store int 12, int* %MyVar2
        ret void
}

to compile to:

foo:
        ldgp $29, 0($27)
        ldiq $0,5
        stl $0,MyVar
        ldiq $0,12
        stl $0,MyVar2
        ret $31,($26),1

instead of:

foo:
        ldgp $29, 0($27)
        bis $29,$29,$0
        ldiq $1,5
        bis $0,$0,$29
        stl $1,MyVar
        ldiq $1,12
        bis $0,$0,$29
        stl $1,MyVar2
        ret $31,($26),1

This does not seem to have any noticable effect on X86 code.

This fixes PR535.

llvm-svn: 20536
2005-03-09 23:05:19 +00:00
Chris Lattner e64ff1c4b2 Silence warnings from VS
llvm-svn: 19386
2005-01-08 19:55:00 +00:00
Reid Spencer 9083936835 For PR387:\
Make only one print method to avoid overloaded virtual warnings when \
compiled with -Woverloaded-virtual

llvm-svn: 18589
2004-12-07 04:03:45 +00:00
Chris Lattner b56cb729bd Reduce usage of MRegisterInfo::getRegClass
llvm-svn: 17238
2004-10-26 05:29:18 +00:00
Chris Lattner 111c3e827e Patch to support MSVC better, contributed by Morten Ofstad
llvm-svn: 17215
2004-10-25 18:40:47 +00:00
Chris Lattner 1905ae69c1 When a virtual register is folded into an instruction, keep track of whether
it was a use, def, or both.  This allows us to be less pessimistic in our
analysis of them.  In practice, this doesn't make a big difference, but it
doesn't hurt either.

llvm-svn: 16632
2004-10-01 23:15:36 +00:00
Chris Lattner f06f4a7c68 Pretty print a bit nicer :)
llvm-svn: 16628
2004-10-01 19:01:39 +00:00
Chris Lattner 55c1402f25 There is no need to call MachineInstr::print directly, just send the MI& to an ostream.
llvm-svn: 16613
2004-09-30 16:10:45 +00:00
Chris Lattner b0b707fc75 * Wrap some comments to 80 cols
* Add const_iterator stuff
* Add a print method, which means that I can now call dump() from the
  debugger.

llvm-svn: 16612
2004-09-30 15:59:17 +00:00
Alkis Evlogimenos 213e6db9ce Grow the map on entry so that we don't crash if joinIntervals never
runs (if coalescing is disabled for example).

llvm-svn: 16259
2004-09-09 19:24:38 +00:00
Alkis Evlogimenos adb2ce2962 Use a DenseMap for mapping reg->reg. This improves the LiveInterval
analysis running time from 2.7869secs to 2.5226secs on 176.gcc.

llvm-svn: 16244
2004-09-08 03:01:50 +00:00
Misha Brukman 14a2b4628d Order #includes alphabetically, local .h files first.
llvm-svn: 16153
2004-09-03 18:25:53 +00:00
Alkis Evlogimenos a5c04ee50f Fixes to make LLVM compile with vc7.1.
Patch contributed by Paolo Invernizzi!

llvm-svn: 16152
2004-09-03 18:19:51 +00:00
Reid Spencer 7c16caa336 Changes For Bug 352
Move include/Config and include/Support into include/llvm/Config,
include/llvm/ADT and include/llvm/Support. From here on out, all LLVM
public header files must be under include/llvm/.

llvm-svn: 16137
2004-09-01 22:55:40 +00:00
Alkis Evlogimenos b84f0be5b1 Minor code clarity changes.
llvm-svn: 16123
2004-08-31 17:39:15 +00:00
Alkis Evlogimenos 8c67a3003e Only update LiveVariables if it is available. addIntervalsForSpills
runs after the initial run of the live interval analysis.

llvm-svn: 16075
2004-08-27 18:59:22 +00:00
Alkis Evlogimenos 542ac1cba7 Use newly added API in MRegisterInfo.
llvm-svn: 16060
2004-08-26 22:22:38 +00:00
Chris Lattner d8b5be4726 Fix a bug in a previous checkin of mine, correcting
Regression.CodeGen.Generic.2004-04-09-SameValueCoalescing.llx and the
code size problem.

This bug prevented us from doing most register coallesces.

llvm-svn: 16031
2004-08-24 17:48:29 +00:00
Chris Lattner 5943c5078c Reduce usage of MRegisterInfo::getRegClass
llvm-svn: 15784
2004-08-15 22:23:09 +00:00
Alkis Evlogimenos 4242241a69 Clean up whitespace.
llvm-svn: 15490
2004-08-04 09:46:56 +00:00
Alkis Evlogimenos a698308cce Convert indentation to 2 spaces.
llvm-svn: 15489
2004-08-04 09:46:26 +00:00
Chris Lattner bbe845b969 Fix the sense of joinable
llvm-svn: 15196
2004-07-25 07:47:25 +00:00
Chris Lattner 83b9c50f8f Fix a bug where we incorrectly value numbered the first PHI definition the
same as the PHI use.  This is not correct as the PHI use value is different
depending on which branch is taken.  This fixes espresso with aggressive
coallescing, and perhaps others.

llvm-svn: 15189
2004-07-25 05:45:18 +00:00
Chris Lattner 0e58e5e48c Add debugging output for joining assignments
llvm-svn: 15187
2004-07-25 03:24:11 +00:00
Alkis Evlogimenos cf72e7f854 Change std::map<unsigned, LiveInterval*> into a std::map<unsigned,
LiveInterval>. This saves some space and removes the pointer
indirection caused by following the pointer.

llvm-svn: 15167
2004-07-24 11:44:15 +00:00
Chris Lattner 8c595eb4bd whoops, didn't mean to remove this
llvm-svn: 15157
2004-07-24 04:32:22 +00:00
Chris Lattner c51866a20e Completely eliminate the intervals_ list. instead, the r2iMap_ maintains
ownership of the intervals.

llvm-svn: 15155
2004-07-24 03:32:06 +00:00
Chris Lattner 7efcdb7ca3 Big change to compute logical value numbers for each LiveRange added to an
Interval.  This generalizes the isDefinedOnce mechanism that we used before
to help us coallesce ranges that overlap.  As part of this, every logical
range with a different value is assigned a different number in the interval.
For example, for code that looks like this:

0  X = ...
4  X += ...
  ...
N    = X

We now generate a live interval that contains two ranges: [2,6:0),[6,?:1)
reflecting the fact that there are two different values in the range at
different positions in the code.

Currently we are not using this information at all, so this just slows down
liveintervals.  In the future, this will change.

Note that this change also substantially refactors the joinIntervalsInMachineBB
method to merge the cases for virt-virt and phys-virt joining into a single
case, adds comments, and makes the code a bit easier to follow.

llvm-svn: 15154
2004-07-24 02:59:07 +00:00
Chris Lattner 1604b02c4c More minor changes:
* Inline some functions
 * Eliminate some comparisons from the release build

This is good for another .3 on gcc.

llvm-svn: 15144
2004-07-23 21:24:19 +00:00
Chris Lattner 856383326a Rename LiveIntervals.(cpp|h) -> LiveIntervalAnalysis.(cpp|h)
llvm-svn: 15135
2004-07-23 17:56:30 +00:00