1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
Commit Graph

203 Commits

Author SHA1 Message Date
Lang Hames
1503988bb5 Modified VNInfo. The "copy" member is now a union which holds the copy for a register interval, or the defining register for a stack interval. Access is via getCopy/setCopy and getReg/setReg.
llvm-svn: 78620
2009-08-10 23:43:28 +00:00
Evan Cheng
a565450757 Another coalescer bug. When a dead copy is eliminated, transfer the kill to a def of the exact register rather than a super-register.
llvm-svn: 78376
2009-08-07 07:14:14 +00:00
Benjamin Kramer
f4e8fdcdd5 Rename a variable to make MSVC happy.
llvm-svn: 78202
2009-08-05 16:08:58 +00:00
Evan Cheng
87e24bb76e Another nasty coalescer bug (is there another kind):
After coalescing reg1027's def and kill are both at the same point:
 %reg1027,0.000000e+00 = [56,814:0)  0@70-(814)

bb5:
60   %reg1027<def> = t2MOVr %reg1027, 14, %reg0, %reg0
68   %reg1027<def> = t2LDRi12 %reg1027<kill>, 8, 14, %reg0
76   t2CMPzri %reg1038<kill,undef>, 0, 14, %reg0, %CPSR<imp-def>
84   %reg1027<def> = t2MOVr %reg1027, 14, %reg0, %reg0
96   t2Bcc mbb<bb5,0x2030910>, 1, %CPSR<kill>

Do not remove the kill marker on t2LDRi12.

llvm-svn: 78178
2009-08-05 07:05:41 +00:00
Evan Cheng
ff81990e49 Fix a coaelescer bug. If a copy val# is extended to eliminate a non-trivially coalesced copy, and the copy kills its source register. Trim the source register's live range to the last use if possible. This fixes up kill marker to make the scavenger happy.
llvm-svn: 77967
2009-08-03 08:41:59 +00:00
Dan Gohman
4529d71681 Use setPreservesAll and setPreservesCFG in CodeGen passes.
llvm-svn: 77754
2009-07-31 23:37:33 +00:00
Chris Lattner
613f031b68 inline the global 'getInstrOperandRegClass' function into its callers
now that TargetOperandInfo does the heavy lifting.

llvm-svn: 77508
2009-07-29 21:36:49 +00:00
Mike Stump
be4029ff76 Avoid build warnings.
llvm-svn: 77271
2009-07-27 23:14:11 +00:00
Daniel Dunbar
8496064116 More migration to raw_ostream, the water has dried up around the iostream hole.
- Some clients which used DOUT have moved to DEBUG. We are deprecating the
   "magic" DOUT behavior which avoided calling printing functions when the
   statement was disabled. In addition to being unnecessary magic, it had the
   downside of leaving code in -Asserts builds, and of hiding potentially
   unnecessary computations.

llvm-svn: 77019
2009-07-25 00:23:56 +00:00
David Greene
7f92a15a4b Make some changes suggested by Bill and Evan.
llvm-svn: 76775
2009-07-22 20:08:25 +00:00
David Greene
ddaf106a0c Add some support for iterative coalescers to calculate a joined live
range's weight properly.  This is turned off right now in the sense that
you'll get an assert if you get into a situation that can only be caused
by an iterative coalescer.  All other code paths operate exactly as
before so there is no functional change with this patch.  The asserts
should be disabled if/when an iterative coalescer gets added to trunk.

llvm-svn: 76680
2009-07-21 23:36:14 +00:00
Evan Cheng
443ae1d494 Cross RC coalescing is now on by default.
llvm-svn: 76519
2009-07-21 00:22:59 +00:00
Evan Cheng
0048e876c3 Fix some sub-reg coalescing bugs where the coalescer wasn't updating the resulting interval's register class.
llvm-svn: 76458
2009-07-20 19:47:55 +00:00
Evan Cheng
a19ee1bb42 Catch more coalescing opportunities.
llvm-svn: 76282
2009-07-18 04:52:23 +00:00
Evan Cheng
84f06f0ee6 Enable cross register class coalescing.
llvm-svn: 76281
2009-07-18 02:10:10 +00:00
Evan Cheng
51593b91d9 Simplify some more.
llvm-svn: 76239
2009-07-17 21:06:58 +00:00
Evan Cheng
ba5b67f66d Simplify the coalescer (finally!) by making LiveIntervals::processImplicitDefs a little more aggressive and teaching liveintervals to make use of isUndef marker on MachineOperands.
llvm-svn: 76223
2009-07-17 19:43:40 +00:00
Evan Cheng
7a6b20df7f Let callers decide the sub-register index on the def operand of rematerialized instructions.
Avoid remat'ing instructions whose def have sub-register indices for now. It's just really really hard to get all the cases right.

llvm-svn: 75900
2009-07-16 09:20:10 +00:00
Evan Cheng
83b99bb014 ShortenDeadCopySrcLiveRange needs to be more conservative in multi-kill situations.
llvm-svn: 75838
2009-07-15 21:39:50 +00:00
Torok Edwin
f955a6ef49 llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.
This adds location info for all llvm_unreachable calls (which is a macro now) in
!NDEBUG builds.
In NDEBUG builds location info and the message is off (it only prints
"UREACHABLE executed").

llvm-svn: 75640
2009-07-14 16:55:14 +00:00
Evan Cheng
9554d9840f Fix pr4544. When remating, make sure the destination register fits the instruction definition. It may be mismatched due to sub-register coalescing.
No test case yet because the code doesn't trigger until 75408 is re-applied.

llvm-svn: 75572
2009-07-14 00:51:06 +00:00
Torok Edwin
ae8a3ff177 assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.

llvm-svn: 75379
2009-07-11 20:10:48 +00:00
Evan Cheng
52ce32d097 Remove TargetInstrInfo::CommuteChangesDestination and added findCommutedOpIndices which returns the operand indices which are swapped (when applicable). This allows for some code clean up and future enhancements.
llvm-svn: 75264
2009-07-10 19:15:51 +00:00
Lang Hames
ceb80b14d3 Improved tracking of value number kills. VN kills are now represented
as an (index,bool) pair. The bool flag records whether the kill is a
PHI kill or not. This code will be used to enable splitting of live
intervals containing PHI-kills.

A slight change to live interval weights introduced an extra spill
into lsr-code-insertion (outside the critical sections). The test 
condition has been updated to reflect this.

llvm-svn: 75097
2009-07-09 03:57:02 +00:00
Evan Cheng
7d78cb531e Remove special handling of implicit_def. Fix a couple more bugs in liveintervalanalysis and coalescer handling of implicit_def.
Note, isUndef marker must be placed even on implicit_def def operand or else the scavenger will not ignore it. This is necessary because -O0 path does not use liveintervalanalysis, it treats implicit_def just like any other def.

llvm-svn: 74601
2009-07-01 08:19:36 +00:00
Evan Cheng
2410955c62 Fix another register coalescer crash: forgot to check if the instruction being updated has already been coalesced.
llvm-svn: 73898
2009-06-22 20:49:32 +00:00
Evan Cheng
82a8ab8a8e - Update register allocation hint after coalescing. This is done by the target since the hint is target dependent. This is important for ARM register pair hints.
- Register allocator should resolve the second part of the hint (register number) before passing it to the target since it knows virtual register to physical register mapping.
- More fixes to get ARM load / store double word working.

llvm-svn: 73671
2009-06-18 02:04:01 +00:00
Lang Hames
5c64015a56 VNInfo cleanup.
llvm-svn: 73634
2009-06-17 21:01:20 +00:00
Evan Cheng
058f158de0 Rename RemoveCopiesFromValNo to TurnCopiesFromValNoToImpDefs.
llvm-svn: 73479
2009-06-16 07:15:05 +00:00
Evan Cheng
a98ff05fca If a val# is defined by an implicit_def and it is being removed, all of the copies off the val# were removed. This causes problem later since the scavenger will see uses of registers without defs. The proper solution is to change the copies into implicit_def's instead.
TurnCopyIntoImpDef turns a copy into implicit_def and remove the val# defined by it. This causes an scavenger assertion later if the def reaches other blocks. Disable the transformation if the value live interval extends beyond its def block.

llvm-svn: 73478
2009-06-16 07:12:58 +00:00
Evan Cheng
3219c7fbe5 Part 1.
- Change register allocation hint to a pair of unsigned integers. The hint type is zero (which means prefer the register specified as second part of the pair) or entirely target dependent.
- Allow targets to specify alternative register allocation orders based on allocation hint.

Part 2.
- Use the register allocation hint system to implement more aggressive load / store multiple formation.
- Aggressively form LDRD / STRD. These are formed *before* register allocation. It has to be done this way to shorten live interval of base and offset registers. e.g.
v1025 = LDR v1024, 0
v1026 = LDR v1024, 0
=>
v1025,v1026 = LDRD v1024, 0

If this transformation isn't done before allocation, v1024 will overlap v1025 which means it more difficult to allocate a register pair.

- Even with the register allocation hint, it may not be possible to get the desired allocation. In that case, the post-allocation load / store multiple pass must fix the ldrd / strd instructions. They can either become ldm / stm instructions or back to a pair of ldr / str instructions.

This is work in progress, not yet enabled.

llvm-svn: 73381
2009-06-15 08:28:29 +00:00
Evan Cheng
1607bd1fa9 Move register allocation preference (or hint) from LiveInterval to MachineRegisterInfo. This allows more passes to set them.
llvm-svn: 73346
2009-06-14 20:22:55 +00:00
Lang Hames
1a81422fab Update to in-place spilling framework. Includes live interval scaling and trivial rewriter.
llvm-svn: 72729
2009-06-02 16:53:25 +00:00
Lang Hames
c577f429c0 Fixed PR4090.
llvm-svn: 71495
2009-05-11 23:14:13 +00:00
Jakob Stoklund Olesen
17d292db73 Join cross class copies using getCommonSubClass()
llvm-svn: 70513
2009-04-30 21:24:03 +00:00
Evan Cheng
a4c868f1d4 Add a smarter heuristic to determine when to coalesce a virtual register with a physical one. More specifically, it avoid tying a virtual register in the loop with a physical register defined / used outside the loop. When it determines it's not profitable, it will use the physical register as the allocation preference instead.
This is *not* turned on by default. Testing indicates this is just as likely to pessimize code. The main issue seems to be allocation preference doesn't work effectively. That will change once I've taught register allocator "swapping".

llvm-svn: 70503
2009-04-30 18:39:57 +00:00
Evan Cheng
46e0ff09e5 Move getMatchingSuperReg() out of coalescer and into TargetRegisterInfo.
llvm-svn: 70309
2009-04-28 18:29:27 +00:00
Jakob Stoklund Olesen
6a489c6d7e Don't coalesce a physical register with an incompatible virtual register.
If the physical register does not belong to the virtual register's regclass,
don't coalesce. The physical register could be an invalid operand for an
instruction using the vreg.

The regclass matching is done after determining the actual subregisters being copied.

llvm-svn: 70298
2009-04-28 16:34:35 +00:00
Owen Anderson
b313524b03 Don't skip the CopyMI when removing kill markers.
This should have no effect on generated code, but makes the intermediate state
of the coalescer more sane.

llvm-svn: 70238
2009-04-27 19:55:47 +00:00
Evan Cheng
ff776c8193 Update comments.
llvm-svn: 69919
2009-04-23 20:39:31 +00:00
Evan Cheng
f20fb20367 Fix an obvious type.
llvm-svn: 69918
2009-04-23 20:18:13 +00:00
Dan Gohman
c9ce27d6b7 Implement support for using modeling implicit-zero-extension on x86-64
with SUBREG_TO_REG, teach SimpleRegisterCoalescing to coalesce
SUBREG_TO_REG instructions (which are similar to INSERT_SUBREG
instructions), and teach the DAGCombiner to take advantage of this on
targets which support it. This eliminates many redundant
zero-extension operations on x86-64.

This adds a new TargetLowering hook, isZExtFree. It's similar to
isTruncateFree, except it only applies to actual definitions, and not
no-op truncates which may not zero the high bits.

Also, this adds a new optimization to SimplifyDemandedBits: transform
operations like x+y into (zext (add (trunc x), (trunc y))) on targets
where all the casts are no-ops. In contexts where the high part of the
add is explicitly masked off, this allows the mask operation to be
eliminated. Fix the DAGCombiner to avoid undoing these transformations
to eliminate casts on targets where the casts are no-ops.

Also, this adds a new two-address lowering heuristic. Since
two-address lowering runs before coalescing, it helps to be able to
look through copies when deciding whether commuting and/or
three-address conversion are profitable.

Also, fix a bug in LiveInterval::MergeInClobberRanges. It didn't handle
the case that a clobber range extended both before and beyond an
existing live range. In that case, multiple live ranges need to be
added. This was exposed by the new subreg coalescing code.

Remove 2008-05-06-SpillerBug.ll. It was bugpoint-reduced, and the
spiller behavior it was looking for no longer occurrs with the new
instruction selection.

llvm-svn: 68576
2009-04-08 00:15:30 +00:00
Bill Wendling
3b2cea6ef5 Fix grammar-o in comment.
llvm-svn: 68057
2009-03-30 20:30:02 +00:00
Evan Cheng
042e05cb31 My last coalescer fix introduced a subtler one. It's aborting a commuting optimization too late and left the live intervals to be out of sync with instructions. This fixes 8b10b.
llvm-svn: 66715
2009-03-11 22:18:44 +00:00
Evan Cheng
264173da40 Two coalescer fixes in one.
1. Use the same value# to represent unknown values being merged into sub-registers.
2. When coalescer commute an instruction and the destination is a physical register, update its sub-registers by merging in the extended ranges.

llvm-svn: 66610
2009-03-11 00:03:21 +00:00
Evan Cheng
41687ff389 If a use operand is marked isKill, don't forget to add kill to its live interval as well.
llvm-svn: 65279
2009-02-22 08:35:56 +00:00
Evan Cheng
2a6fc3cd40 Fix another case ShortenDeadCopySrcLiveRange is shortening too much. No test case possible since I don't know what to grep for. :-(
llvm-svn: 64125
2009-02-09 08:37:45 +00:00
Evan Cheng
a7287a61fb Fix PR3486. Fix a bug in code that manually patch physical register live interval after its sub-register is coalesced with a virtual register.
llvm-svn: 64082
2009-02-08 11:04:35 +00:00
Evan Cheng
b5792305b3 Strengthen the previous check.
llvm-svn: 64076
2009-02-08 08:24:28 +00:00
Evan Cheng
d5f5c0660b r64073 commit message is lost. Here it is:
Right now if the coalesced copy def is dead and its src is a kill, and that
there are now other uses within the live range, the coalescer would mark the
def of the source register as dead. But it should also check if there are
other kills which means the value has other uses not in the live range.

llvm-svn: 64075
2009-02-08 08:00:36 +00:00