Commit Graph

127 Commits

Author SHA1 Message Date
Dale Johannesen 9af7b3daec Teach coalescer about earlyclobber bits.
Check bits for preferred register.

llvm-svn: 56384
2008-09-20 02:03:04 +00:00
Evan Cheng 29e4c9192d Continue after removing the current MI.
llvm-svn: 56372
2008-09-19 22:49:39 +00:00
Evan Cheng 4c0197043c Re-materalized definition instructions may be dead. Whack them.
llvm-svn: 56352
2008-09-19 17:38:47 +00:00
Evan Cheng f3fcd7a464 Unallocatable registers do not have live intervals.
llvm-svn: 56287
2008-09-17 18:36:25 +00:00
Evan Cheng 02acc35abd Correctly update kill infos after extending a live range and merge 2 val#'s; fix 56165 - do not mark val# copy field if the copy does not define the val#.
llvm-svn: 56199
2008-09-15 06:28:41 +00:00
Dan Gohman 38453eebdc Remove isImm(), isReg(), and friends, in favor of
isImmediate(), isRegister(), and friends, to avoid confusion
about having two different names with the same meaning. I'm
not attached to the longer names, and would be ok with
changing to the shorter names if others prefer it.

llvm-svn: 56189
2008-09-13 17:58:21 +00:00
Evan Cheng 3c12fc4342 On some targets, non-move instructions can become move instructions because of coalescing. e.g.
vr2 = OR vr0, vr1
=>
vr2 = OR vr1, vr1   // after coalescing vr0 with vr1

Update the value# of the destination register with the copy instruction if that happens.

llvm-svn: 56165
2008-09-12 18:13:14 +00:00
Evan Cheng 5456a37280 Fix PR2748. Avoid coalescing physical register with virtual register which would create illegal extract_subreg. e.g.
vr1024 = extract_subreg vr1025, 1
...
vr1024 = mov8rr AH
If vr1024 is coalesced with AH, the extract_subreg is now illegal since AH does not have a super-reg whose sub-register 1 is AH.

llvm-svn: 56118
2008-09-11 20:07:10 +00:00
Evan Cheng 4c9fbbb511 Fix PR2783 - coalescer bug. Missing a TargetRegisterInfo::isVirtualRegister check.
llvm-svn: 56112
2008-09-11 18:40:32 +00:00
Owen Anderson 7591130946 Fix a bug in the coalescer where it didn't check if a live interval existed before trying to manipulate it. This
was exposed by fast isel's handling of shifts on X86-64.  With this, FreeBench/pcompress2 passes on X86-64 in fast isel.

llvm-svn: 56067
2008-09-10 20:41:13 +00:00
Evan Cheng c6db3ad15f Fix typo.
llvm-svn: 56037
2008-09-10 00:30:50 +00:00
Evan Cheng 93945287b8 Clear preference when it no longer makes sense.
llvm-svn: 56019
2008-09-09 21:44:23 +00:00
Evan Cheng a3771d5bd9 Re-apply 55467 with fix. If copy is being replaced by remat'ed def, transfer the implicit defs onto the remat'ed instruction.
llvm-svn: 55564
2008-08-30 09:09:33 +00:00
Dan Gohman 04cf2e4540 Revert r55467; it causes regressions in UnitTests/Vector/divides,
Benchmarks/sim/sim, and others on x86-64.

llvm-svn: 55475
2008-08-28 17:22:54 +00:00
Evan Cheng 6975602024 If a copy isn't coalesced, but its src is defined by trivial computation. Re-materialize the src to replace the copy.
llvm-svn: 55467
2008-08-28 07:53:51 +00:00
Owen Anderson 4f6bf04616 Convert uses of std::vector in TargetInstrInfo to SmallVector. This change had to be propoagated down into all the targets and up into all clients of this API.
llvm-svn: 54802
2008-08-14 22:49:33 +00:00
Dan Gohman 8de6d22392 Use empty() instead of begin() == end().
llvm-svn: 54780
2008-08-14 18:13:49 +00:00
Owen Anderson 51f689a652 Make the allocation of LiveIntervals explicit, rather than holding them in the r2iMap_ by value. This will prevent references to them from being invalidated
if the map is changed.

llvm-svn: 54763
2008-08-13 21:49:13 +00:00
Evan Cheng a4d6d884d6 Remove #if 0.
llvm-svn: 54347
2008-08-05 07:20:57 +00:00
Evan Cheng 0ca10c9572 Fix PR2568: Fix bug that cause redudant kill marker after its live interval has been extended due to coalescing.
llvm-svn: 54346
2008-08-05 07:10:38 +00:00
Owen Anderson 7c800ad977 Fix a compile-time regression introduced by my heuristic-changing patch. I forgot
to multiply the instruction count by a constant factor in a few places, which
caused the register allocator to require many more iterations.

llvm-svn: 53959
2008-07-23 19:47:27 +00:00
Owen Anderson 029182f3a3 Change the heuristics used in the coalescer, register allocator, and within
live intervals itself to use an instruction count approximation that is 
not affected by inserting empty indices.

llvm-svn: 53937
2008-07-22 22:46:49 +00:00
Evan Cheng cefd6e62fa Subreg live interval valno may not have a corresponding def machineinstr since it's less precise.
llvm-svn: 53734
2008-07-17 19:48:53 +00:00
Owen Anderson 79d2fa52fa Use getMBBEndIdx rather than assuming that the end is right after the last instruction in the block.
llvm-svn: 52649
2008-06-23 22:12:23 +00:00
Evan Cheng f593a65497 Undo spill weight tweak. Need to investigate the performance regressions.
llvm-svn: 52572
2008-06-21 06:45:54 +00:00
Evan Cheng 0c8ef553f5 Coalesce copy from one register class to a sub register class. e.g. X86::MOV16to16_.
llvm-svn: 52480
2008-06-19 01:39:21 +00:00
Evan Cheng 1eb69314fa When extending a liveinterval by commuting, don't throw away the live ranges that are not affected.
llvm-svn: 52430
2008-06-17 20:11:16 +00:00
Owen Anderson c5e21e4f38 The coalescer doesn't need LiveVariables now that we have register use iterators.
llvm-svn: 51790
2008-05-30 22:37:27 +00:00
Evan Cheng 68079268f5 Fix PR2289: vr defined by multiple implicit_def as result of coalescing.
llvm-svn: 51648
2008-05-28 17:40:10 +00:00
Evan Cheng a5d27ae586 Fix PR2343. An *interesting* coalescer bug.
BB1:                                                                                                                                                  
  vr1025 = copy vr1024                                                                                                                                
  ..                                                                                                                                                  
BB2:                                                                                                                                                  
  vr1024 = op                                                                                                                                         
         = op vr1025                                                                                                                                     
  <loop eventually branch back to BB1>

Even though vr1025 is copied from vr1024, it's not safe to coalesced them since live range of vr1025 intersects the def of vr1024. This happens when vr1025 is assigned the value of the previous iteration of vr1024 in the loop.

llvm-svn: 51394
2008-05-21 22:34:12 +00:00
Dan Gohman 0479aa5c0b Change class' public PassInfo variables to by initialized with the
address of the PassInfo directly instead of calling getPassInfo.
This eliminates a bunch of dynamic initializations of static data.

Also, fold RegisterPassBase into PassInfo, make a bunch of its
data members const, and rearrange some code to initialize data
members in constructors instead of using setter member functions.

llvm-svn: 51022
2008-05-13 02:05:11 +00:00
Dan Gohman d78c400b5b Clean up the use of static and anonymous namespaces. This turned up
several things that were neither in an anonymous namespace nor static
but not intended to be global.

llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Evan Cheng 11b98b6612 Another extract_subreg coalescing bug.
e.g.
vr1024<2> extract_subreg vr1025, 2
If vr1024 do not have the same register class as vr1025, it's not safe to coalesce this away. For example, vr1024 might be a GPR32 while vr1025 might be a GPR64.

llvm-svn: 50385
2008-04-29 01:41:44 +00:00
Evan Cheng 3980a7911a - Check if a register is livein before removing it. It may have already been removed.
- Do not iterate over SmallPtrSet, the order of iteration is not deterministic.

llvm-svn: 50209
2008-04-24 09:06:33 +00:00
Evan Cheng d556115e7e Correct comment.
llvm-svn: 49913
2008-04-18 19:25:26 +00:00
Evan Cheng 495a516390 Not safe to "kill" a register if its live range extends pass the end of block branch.
llvm-svn: 49911
2008-04-18 19:22:23 +00:00
Evan Cheng 7e4a55bc58 Be more careful with insert_subreg and extract_subreg where either source or destination operand has already been coalesced with another register that's defined by a insert_subreg or extract_subreg.
llvm-svn: 49843
2008-04-17 07:58:04 +00:00
Bill Wendling 288ef83b8a Use correct name for method in comment.
llvm-svn: 49841
2008-04-17 05:20:39 +00:00
Evan Cheng c8c3a899c0 Fix a sub-register indice propagation bug.
llvm-svn: 49832
2008-04-17 00:06:42 +00:00
Evan Cheng 59aa126e48 After reading memory that's already freed.
llvm-svn: 49810
2008-04-16 20:24:25 +00:00
Evan Cheng 23f12757ed Fix PR2226. Avoid using uninitialized variables.
llvm-svn: 49807
2008-04-16 18:48:43 +00:00
Evan Cheng e29e9774a4 Avoid read after free.
llvm-svn: 49760
2008-04-16 01:22:28 +00:00
Evan Cheng c6864b6652 Remove implicit_def instructions that become dead as result of coalescing.
llvm-svn: 49513
2008-04-10 23:48:35 +00:00
Evan Cheng 16ea87d6ee A copy instruction may use a register multiple times on some targets. Change them all.
llvm-svn: 49491
2008-04-10 18:38:47 +00:00
Evan Cheng c8eeb752a3 - More aggressively coalescing away copies whose source is defined by an implicit_def.
- Added insert_subreg coalescing support.

llvm-svn: 49448
2008-04-09 20:57:25 +00:00
Evan Cheng aa3b55f842 Missed a hasInterval check.
llvm-svn: 49415
2008-04-09 01:30:15 +00:00
Evan Cheng 58936a48ee - Turn copies of implicit_def into implicit_def instructions.
- Be smarter about coalescing copies from implicit_def.

llvm-svn: 49168
2008-04-03 16:41:54 +00:00
Evan Cheng db390694ff One more coalescer fix wrt deadness propagation.
llvm-svn: 48837
2008-03-26 20:15:49 +00:00
Evan Cheng 289ba4f335 Avoid commuting a def MI in order to coalesce a copy instruction away if any use of the same val# is a copy instruction that has already been coalesced.
llvm-svn: 48833
2008-03-26 19:03:01 +00:00
Evan Cheng 7d564c3b4a lastRegisterUse() should ignore identity copies. Those will be erased.
llvm-svn: 48759
2008-03-25 02:02:19 +00:00