Commit Graph

72 Commits

Author SHA1 Message Date
Evan Cheng
4ff3f1cc57 - Fix a subtle bug in RemoveCopyByCommutingDef. ALR is the live range where the source is defined; BLR is the live range which is defined by the copy.
If ALR and BLR overlaps and end of BLR extends beyond end of ALR, e.g.                                                                                                 
 A = or A, B                                                                                                                                                            
 ...                                                                                                                                                                    
 B = A                                                                                                                                                                  
 ...                                                                                                                                                                    
 C = A<kill>                                                                                                                                                            
 ...                                                                                                                                                                    
   = B                                                                                                                                                                  
                                                                                                                                                                        
then do not add kills of A to the newly created B interval.
- Also fix some kill info update bug.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48141 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-10 08:11:32 +00:00
Evan Cheng
ecb2a8b9bc Fix a coalescer bug wrt how dead copy interval is shortened.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47966 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-05 22:09:42 +00:00
Evan Cheng
6130f66eaa Refactor code. Remove duplicated functions that basically do the same thing as
findRegisterUseOperandIdx, findRegisterDefOperandIndx. Fix some naming inconsistencies.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47927 91177308-0d34-0410-b5e6-96231b3b80d8
2008-03-05 00:59:57 +00:00
Evan Cheng
bec2c0c7e1 No need for coalescer to update kills. Only copies are coalesced and those instructions will be deleted. Doh.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47749 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-29 02:50:03 +00:00
Bill Wendling
e6d088acc9 Rename PrintableName to Name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47629 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 21:47:57 +00:00
Bill Wendling
74ab84c31e Change "Name" to "AsmName" in the target register info. Gee, a refactoring tool
would have been a Godsend here!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47625 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 21:11:01 +00:00
Evan Cheng
4d535cadf1 Enable -coalescer-commute-instrs by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47623 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 20:40:22 +00:00
Evan Cheng
c886c460e4 This is possible:
vr1 = extract_subreg vr2, 3
...
vr3 = extract_subreg vr1, 2
The end result is vr3 is equal to vr2 with subidx 2.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47592 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-26 08:03:41 +00:00
Evan Cheng
becda48f88 Fix compiler warning.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47468 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-22 01:48:00 +00:00
Evan Cheng
304983b93e Help testing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47448 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-21 19:20:21 +00:00
Evan Cheng
a9407f5937 - Remove the previous check which broke coalescer-commute3.ll
- For now, conservatively ignore copy MI whose source is a physical register. Commuting its def MI can cause a physical register live interval to be live through a loop (since we know it's live coming into the def MI).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47281 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-18 18:56:31 +00:00
Evan Cheng
96cfff0906 For now, avoid commuting def MI for copy MI's whose source is not killed. That simply trade a live interval for another and because only the non-two-address operands can be folded into loads, may end up pessimising code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47262 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-18 08:40:53 +00:00
Evan Cheng
559f4224d6 Refactor some code; check if commuteInstruction is able to commute the instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47208 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-16 02:32:17 +00:00
Evan Cheng
bd3e5aac74 The copy instruction being coalesced will be removed, it is not a kill.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47179 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 21:36:51 +00:00
Evan Cheng
c8d044e4f7 - Removing the infamous r2rMap_ and rep() method. Now the coalescer will update
register defs and uses after each successful coalescing.
- Also removed a number of hacks and fixed some subtle kill information bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47167 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-15 18:24:29 +00:00
Evan Cheng
cdbcfccece Some code clean up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47060 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 09:56:03 +00:00
Evan Cheng
e35a6d1dfb * Cannot safely commute an instruction there are other defs which can reach its uses.
* Ignore copy instructions which have already been coalesced.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47056 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 08:41:08 +00:00
Evan Cheng
70071434ae Initial support for copy elimination by commuting its definition MI.
PR1877.
A3 = op A2 B0<kill>                                                                                                                                                                            
...                                                                                                                                                                                     
B1 = A3      <- this copy                                                                                                                                                                      
...                                                                                                                                                                                          
   = op A3   <- more uses                                                                                                                                                                      
                                                                                                                                                                                                 
==>                                                                                                                                                                                             
                                                                                                                                                                                            
B2 = op B0 A2<kill>                                                                                                                                                                            
...                                                                                                                                                                                          
B1 = B2      <- now an identify copy                                                                                                                                                           
...                                                                                                                                                                                          
   = op B2   <- more uses

This speeds up FreeBench/neural by 29%, Olden/bh by 12%, oopack_v1p8 by 53%.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47046 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-13 03:01:43 +00:00
Dan Gohman
6f0d024a53 Rename MRegisterInfo to TargetRegisterInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46930 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-10 18:45:23 +00:00
Evan Cheng
63a18c491a Remove unused hidden option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46903 91177308-0d34-0410-b5e6-96231b3b80d8
2008-02-09 08:36:28 +00:00
Bill Wendling
67d65bb69d Don't recalculate the loop info and loop dominators analyses if they're
preserved.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45596 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 20:54:55 +00:00
Bill Wendling
2674d71df0 80-column violations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45574 91177308-0d34-0410-b5e6-96231b3b80d8
2008-01-04 08:59:18 +00:00
Chris Lattner
534bcfb270 update a couple of references to SSARegMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45468 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:16:08 +00:00
Chris Lattner
84bc5427d6 Rename SSARegMap -> MachineRegisterInfo in keeping with the idea
that "machine" classes are used to represent the current state of
the code being compiled.  Given this expanded name, we can start 
moving other stuff into it.  For now, move the UsedPhysRegs and
LiveIn/LoveOuts vectors from MachineFunction into it.

Update all the clients to match.

This also reduces some needless #includes, such as MachineModuleInfo
from MachineFunction.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45467 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-31 04:13:23 +00:00
Chris Lattner
f73823000e More cleanups for MachineOperand:
- Eliminate the static "print" method for operands, moving it
    into MachineOperand::print.
  - Change various set* methods for register flags to take a bool
    for the value to set it to.  Remove unset* methods.
  - Group methods more logically by operand flavor in MachineOperand.h


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45461 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-30 21:56:09 +00:00
Chris Lattner
4ee451de36 Remove attribution from file headers, per discussion on llvmdev.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45418 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-29 20:36:04 +00:00
Evan Cheng
689494208b The physical register + virtual register joining requirement was much too strict.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45253 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-20 02:23:25 +00:00
Evan Cheng
22f07ffd27 Switch over to MachineLoopInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44838 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-11 02:09:15 +00:00
Evan Cheng
dfb1561434 Add an option to control this heuristic tweak so I can test it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44671 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-07 00:28:32 +00:00
Evan Cheng
5ef3a04b54 Fix for PR1831: if all defs of an interval are re-materializable, then it's a preferred spill candiate.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44644 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-06 00:01:56 +00:00
Evan Cheng
c3fc7d9ec9 Replace the odd kill# hack with something less fragile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44434 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-29 09:49:23 +00:00
Evan Cheng
81a0382181 Live interval splitting:
When a live interval is being spilled, rather than creating short, non-spillable
intervals for every def / use, split the interval at BB boundaries. That is, for
every BB where the live interval is defined or used, create a new interval that
covers all the defs and uses in the BB.

This is designed to eliminate one common problem: multiple reloads of the same
value in a single basic block. Note, it does *not* decrease the number of spills
since no copies are inserted so the split intervals are *connected* through
spill and reloads (or rematerialization). The newly created intervals can be
spilled again, in that case, since it does not span multiple basic blocks, it's
spilled in the usual manner. However, it can reuse the same stack slot as the
previously split interval.

This is currently controlled by -split-intervals-at-bb.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44198 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-17 00:40:40 +00:00
Evan Cheng
c498b0281f Clean up sub-register implementation by moving subReg information back to
MachineOperand auxInfo. Previous clunky implementation uses an external map
to track sub-register uses. That works because register allocator uses
a new virtual register for each spilled use. With interval splitting (coming
soon), we may have multiple uses of the same register some of which are
of using different sub-registers from others. It's too fragile to constantly
update the information.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44104 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-14 07:59:08 +00:00
Evan Cheng
f2fbca68f8 Refactor some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44010 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-12 06:35:08 +00:00
Evan Cheng
8fc9a10221 First step towards moving the coalescer to priority_queue based machinery.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43764 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-06 08:52:21 +00:00
Evan Cheng
a461c4d75b Move SimpleRegisterCoalescing.h to lib/CodeGen since there is now a common
register coalescer interface: RegisterCoalescing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43714 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 17:41:38 +00:00
Evan Cheng
5031fd2d32 Skip over deleted val#'s.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43700 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 06:46:45 +00:00
Evan Cheng
0547bab214 - Coalesce extract_subreg when both intervals are relatively small.
- Some code clean up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43606 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 06:22:48 +00:00
Evan Cheng
4ae31a5d32 Really fix PR1734. Carefully track which register uses are sub-register uses by
traversing inverse register coalescing map.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43118 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 07:49:59 +00:00
Evan Cheng
95f0ab624d One more extract_subreg coalescing bug fix.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43065 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 05:29:37 +00:00
Evan Cheng
dcd8f78f8a Fix PR1734.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43035 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 19:29:47 +00:00
Evan Cheng
8b0b874987 Code clean up.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43026 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-16 08:04:24 +00:00
Evan Cheng
f5c7359afa Fix PR1729: watch out for val# with no def.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42996 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-15 18:33:50 +00:00
Evan Cheng
34729256e8 When coalescing an EXTRACT_SUBREG and the dst register is a physical register,
the source register will be coalesced to the super register of the LHS. Properly
merge in the live ranges of the resulting coalesced interval that were part of
the original source interval to the live interval of the super-register.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42961 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-14 10:08:34 +00:00
Evan Cheng
52c7ff7067 Restrict EXTRACT_SUBREG coalescing to avoid negative performance impact.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42903 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 09:15:53 +00:00
Evan Cheng
32dfbeada7 EXTRACT_SUBREG coalescing support. The coalescer now treats EXTRACT_SUBREG like
(almost) a register copy. However, it always coalesced to the register of the
RHS (the super-register). All uses of the result of a EXTRACT_SUBREG are sub-
register uses which adds subtle complications to load folding, spiller rewrite,
etc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42899 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 08:50:34 +00:00
Evan Cheng
be8db245f5 Bad choice of variable name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42821 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-10 00:11:40 +00:00
Evan Cheng
5edc57fa42 Fix an extremely stupid bug that prevented first round of coalescing (physical registers only) from happening.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42820 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-09 23:36:27 +00:00
Dan Gohman
92dfe2001e Remove isReg, isImm, and isMBB, and change all their users to use
isRegister, isImmediate, and isMachineBasicBlock, which are equivalent,
and more popular.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41958 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-14 20:33:02 +00:00
David Greene
2c17c4d8d9 Pluggable coalescers inplementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-06 16:18:45 +00:00