1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
Commit Graph

254 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
b6f6f2baa9 Optimize reserved register coalescing.
Reserved registers don't have proper live ranges, their LiveInterval
simply has a snippet of liveness for each def.  Virtual registers with a
single value that is a copy of a reserved register (typically %esp) can
be coalesced with the reserved register if the live range doesn't
overlap any reserved register defs.

When coalescing with a reserved register, don't modify the reserved
register live range.  Just leave it as a bunch of dead defs.  This
eliminates quadratic coalescer behavior in i386 functions with many
function calls.

PR11699

llvm-svn: 147726
2012-01-07 07:39:50 +00:00
Jakob Stoklund Olesen
3221d31706 Use the 'regalloc' debug tag for most register allocator tracing.
llvm-svn: 147725
2012-01-07 07:39:47 +00:00
Pete Cooper
5e48c1e8e3 Reverting r145899 as it breaks clang self-hosting
llvm-svn: 146136
2011-12-08 03:24:10 +00:00
Evan Cheng
1acd685d87 Add bundle aware API for querying instruction properties and switch the code
generator to it. For non-bundle instructions, these behave exactly the same
as the MC layer API.

For properties like mayLoad / mayStore, look into the bundle and if any of the
bundled instructions has the property it would return true.
For properties like isPredicable, only return true if *all* of the bundled
instructions have the property.
For properties like canFoldAsLoad, isCompare, conservatively return false for
bundles.

llvm-svn: 146026
2011-12-07 07:15:52 +00:00
Evan Cheng
5061553f9d First chunk of MachineInstr bundle support.
1. Added opcode BUNDLE
2. Taught MachineInstr class to deal with bundled MIs
3. Changed MachineBasicBlock iterator to skip over bundled MIs; added an iterator to walk all the MIs
4. Taught MachineBasicBlock methods about bundled MIs

llvm-svn: 145975
2011-12-06 22:12:01 +00:00
Pete Cooper
61ffb8fcc5 Removed isWinToJoinCrossClass from the register coalescer.
The new register allocator is much more able to split back up ranges too constrained by register classes.

Fixes <rdar://problem/10466609>

llvm-svn: 145899
2011-12-06 02:06:50 +00:00
Jakob Stoklund Olesen
9b34607bdf Rename SlotIndexes to match how they are used.
The old naming scheme (load/use/def/store) can be traced back to an old
linear scan article, but the names don't match how slots are actually
used.

The load and store slots are not needed after the deferred spill code
insertion framework was deleted.

The use and def slots don't make any sense because we are using
half-open intervals as is customary in C code, but the names suggest
closed intervals.  In reality, these slots were used to distinguish
early-clobber defs from normal defs.

The new naming scheme also has 4 slots, but the names match how the
slots are really used.  This is a purely mechanical renaming, but some
of the code makes a lot more sense now.

llvm-svn: 144503
2011-11-13 20:45:27 +00:00
Jakob Stoklund Olesen
6791856e46 Remove unused DstSubIdx argument.
llvm-svn: 141214
2011-10-05 21:22:53 +00:00
Jakob Stoklund Olesen
5b02a59087 Also add <def,undef> flags when coalescing sub-registers.
RegisterCoalescer can create sub-register defs when it is joining a
register with a sub-register.  Add <undef> flags to these new
sub-register defs where appropriate.

llvm-svn: 141138
2011-10-05 00:01:46 +00:00
Jakob Stoklund Olesen
b0b79fa82c Move getCommonSubClass() into TRI.
It will soon need the context.

llvm-svn: 140896
2011-09-30 22:18:51 +00:00
Jakob Stoklund Olesen
08e2c3836e Revert r139782, "RemoveCopyByCommutingDef doesn't need hasPHIKill()."
It does, after all.

RemoveCopyByCommutingDef rewrites the uses of one particular value
number in A. It doesn't know how to rewrite phi uses, so there can't be
any.

llvm-svn: 139787
2011-09-15 06:27:32 +00:00
Jakob Stoklund Olesen
f6c29ab2d4 RemoveCopyByCommutingDef doesn't need hasPHIKill().
Instead, let HasOtherReachingDefs() test for defs in B that overlap any
phi-defs in A as well.  This test is slightly different, but almost
identical.

A perfectly precise test would only check those phi-defs in A that are
reachable from AValNo.

llvm-svn: 139782
2011-09-15 05:03:50 +00:00
Jakob Stoklund Olesen
2c232210b1 It is safe to remat a value killed by phis.
The source live range is recomputed using shrinkToUses() which does
handle phis correctly.  The hasPHIKill() condition was relevant in the
old days when ReMaterializeTrivialDef() tried to recompute the live
range itself.

The shrinkToUses() function will mark the original def as dead when no
more uses and phi kills remain.  It is then removed by
runOnMachineFunction().

llvm-svn: 139781
2011-09-15 04:52:06 +00:00
Andrew Trick
e5bb7267ff [regcoalescing] bug fix for RegistersDefinedFromSameValue.
An improper SlotIndex->VNInfo lookup was leading to unsafe copy removal.
Fixes PR10920 401.bzip2 miscompile with no IV rewrite.

llvm-svn: 139765
2011-09-15 01:09:33 +00:00
Jakob Stoklund Olesen
d10a0768cb Simplify by using isFullCopy().
llvm-svn: 139019
2011-09-02 18:18:29 +00:00
Jakob Stoklund Olesen
e43aca1c39 Inflate register classes after coalescing.
Coalescing can remove copy-like instructions with sub-register operands
that constrained the register class.  Examples are:

  x86: GR32_ABCD:sub_8bit_hi -> GR32
  arm: DPR_VFP2:ssub0 -> DPR

Recompute the register class of any virtual registers that are used by
less instructions after coalescing.

This affects code generation for the Cortex-A8 where we use NEON
instructions for f32 operations, c.f. fp_convert.ll:

  vadd.f32  d16, d1, d0
  vcvt.s32.f32  d0, d16

The register allocator is now free to use d16 for the temporary, and
that comes first in the allocation order because it doesn't interfere
with any s-registers.

llvm-svn: 137133
2011-08-09 18:19:41 +00:00
Jakob Stoklund Olesen
4872d9f414 Rename member variables to follow coding standards.
No functional change.

llvm-svn: 137094
2011-08-09 01:01:27 +00:00
Jakob Stoklund Olesen
ef49b7bc1a Move the RegisterCoalescer private to its implementation file.
RegisterCoalescer.h still has the CoalescerPair class interface.

llvm-svn: 137088
2011-08-09 00:43:37 +00:00
Jakob Stoklund Olesen
2f58336f2f Refer to the RegisterCoalescer pass by ID.
A public interface is no longer needed since RegisterCoalescer is not an
analysis any more.

llvm-svn: 137082
2011-08-09 00:29:53 +00:00
Jakob Stoklund Olesen
3f729850d3 Eliminate copies of undefined values during coalescing.
These copies would coalesce easily, but the resulting value would be
defined by a deleted instruction. Now we also remove the undefined value
number from the destination register.

This fixes PR10503.

llvm-svn: 136174
2011-07-26 23:00:24 +00:00
Rafael Espindola
f04e6b50ca Fix an easy fixme.
llvm-svn: 134364
2011-07-03 05:26:42 +00:00
Rafael Espindola
cf67208057 Use getVNInfoAt.
llvm-svn: 134312
2011-07-02 07:50:27 +00:00
Rafael Espindola
a8c92aa8ef Check the VN of the src register at the two copies, not just the
register number.

llvm-svn: 134309
2011-07-02 05:34:02 +00:00
Duncan Sands
cfea0dd707 Disable commit 134216 ("Add 134199 back, but disable the optimization when the second
copy is a kill") to see if it fixes the i386 dragonegg buildbot, which is timing out
because gcc built with dragonegg is going into an infinite loop.

llvm-svn: 134237
2011-07-01 12:01:00 +00:00
Rafael Espindola
ac24a57bdb Avoid DenseMap lookup.
llvm-svn: 134231
2011-07-01 04:15:02 +00:00
Rafael Espindola
0b7dda94fb Fix off by one error. I misunderstood the comment about killedAt.
llvm-svn: 134229
2011-07-01 03:31:29 +00:00
Rafael Espindola
0a0153608f Check the liveinterval, not the kill flag.
llvm-svn: 134228
2011-07-01 02:35:06 +00:00
Rafael Espindola
c09ce29b8b Add 134199 back, but disable the optimization when the second copy is a kill.
llvm-svn: 134216
2011-07-01 00:16:54 +00:00
Rafael Espindola
6201f80bc0 Revert my previous patch while I debug llvm-gcc bootstrap.
llvm-svn: 134201
2011-06-30 22:58:17 +00:00
Rafael Espindola
63769912fc Don't give up on coalescing A and B when we find
A = X
B = X

Instead, proceed as if we had found

A = X
B = A

llvm-svn: 134199
2011-06-30 22:24:13 +00:00
Rafael Espindola
734b5851f6 make compose and isMoveInstr static functions.
llvm-svn: 134093
2011-06-29 20:55:48 +00:00
Evan Cheng
4a169be530 - Rename TargetInstrDesc, TargetOperandInfo to MCInstrDesc and MCOperandInfo and
sink them into MC layer.
- Added MCInstrInfo, which captures the tablegen generated static data. Chang
TargetInstrInfo so it's based off MCInstrInfo.

llvm-svn: 134021
2011-06-28 19:10:37 +00:00
Evan Cheng
2c06c8b3c2 More refactoring. Move getRegClass from TargetOperandInfo to TargetInstrInfo.
llvm-svn: 133944
2011-06-27 21:26:13 +00:00
Rafael Espindola
45a2fa5664 There is only one register coalescer. Merge it into the base class and
remove the analysis group.

llvm-svn: 133899
2011-06-26 22:34:10 +00:00
Rafael Espindola
50c3048b1f Merge SimpleRegisterCoalescing.cpp into RegisterCoalescer.cpp.
llvm-svn: 133897
2011-06-26 22:06:36 +00:00
Rafael Espindola
7ad658a832 Move RegisterCoalescer.h to lib/CodeGen.
llvm-svn: 133895
2011-06-26 21:41:06 +00:00
Owen Anderson
c65395a991 Analysis groups need to initialize their default implementations.
llvm-svn: 116441
2010-10-13 21:49:58 +00:00
Owen Anderson
69cbf2e8b7 Now with fewer extraneous semicolons!
llvm-svn: 115996
2010-10-07 22:25:06 +00:00
Owen Anderson
2a670815f6 Hide analysis group registration behind a macro, just like pass registration.
llvm-svn: 115835
2010-10-06 21:02:27 +00:00
Jakob Stoklund Olesen
bcee53a2b8 Remove many calls to TII::isMoveInstr. Targets should be producing COPY anyway.
TII::isMoveInstr is going tobe completely removed.

llvm-svn: 108507
2010-07-16 04:45:42 +00:00
Jakob Stoklund Olesen
30aacf68b9 Convert EXTRACT_SUBREG to COPY when emitting machine instrs.
EXTRACT_SUBREG no longer appears as a machine instruction. Use COPY instead.

Add isCopy() checks in many places using isMoveInstr() and isExtractSubreg().
The isMoveInstr hook will be removed later.

llvm-svn: 107879
2010-07-08 16:40:22 +00:00
Jakob Stoklund Olesen
8983ea915c Remove references to INSERT_SUBREG after de-SSA.
Fix X86InstrInfo::convertToThreeAddressWithLEA to generate COPY instead of
INSERT_SUBREG.

llvm-svn: 107878
2010-07-08 16:40:15 +00:00
Jakob Stoklund Olesen
3f4e5779d7 Revert "Remove references to INSERT_SUBREG after de-SSA" r107725.
Buildbot breakage.

llvm-svn: 107744
2010-07-07 00:32:25 +00:00
Jakob Stoklund Olesen
04124836b5 Remove references to INSERT_SUBREG after de-SSA
llvm-svn: 107732
2010-07-06 23:40:35 +00:00
Jakob Stoklund Olesen
f86de96f78 Be more forgiving when calculating alias interference for physreg coalescing.
It is OK for an alias live range to overlap if there is a copy to or from the
physical register. CoalescerPair can work out if the copy is coalescable
independently of the alias.

This means that we can join with the actual destination interval instead of
using the getOrigDstReg() hack. It is no longer necessary to merge clobber
ranges into subregisters.

llvm-svn: 107695
2010-07-06 20:31:51 +00:00
Jakob Stoklund Olesen
dba28ee3d8 Detect and handle COPY in many places.
This code is transitional, it will soon be possible to eliminate
isExtractSubreg, isInsertSubreg, and isMoveInstr in most places.

llvm-svn: 107547
2010-07-03 00:04:37 +00:00
Jakob Stoklund Olesen
f01eb3aab6 Be more strict about subreg-to-subreg copies in CoalescerPair.
Also keep track of the original DstREg before subregister adjustments.

llvm-svn: 106753
2010-06-24 16:19:28 +00:00
Jakob Stoklund Olesen
1c9d50ed92 Revert "Replace a big gob of old coalescer logic with the new CoalescerPair class."
Whiny buildbots.

llvm-svn: 106710
2010-06-24 00:52:22 +00:00
Jakob Stoklund Olesen
19abbf4387 Replace a big gob of old coalescer logic with the new CoalescerPair class.
CoalescerPair can determine if a copy can be coalesced, and which register gets
merged away. The old logic in SimpleRegisterCoalescing had evolved into
something a bit too convoluted.

llvm-svn: 106701
2010-06-24 00:12:39 +00:00
Jakob Stoklund Olesen
f9a94f9154 Add CoalescerPair helper class.
Given a copy instruction, CoalescerPair can determine which registers to
coalesce in order to eliminate the copy. It deals with all the subreg fun to
determine a tuple (DstReg, SrcReg, SubIdx) such that:

- SrcReg is a virtual register that will disappear after coalescing.
- DstReg is a virtual or physical register whose live range will be extended.
- SubIdx is 0 when DstReg is a physical register.
- SrcReg can be joined with DstReg:SubIdx.

CoalescerPair::isCoalescable() determines if another copy instruction is
compatible with the same tuple. This fixes some NEON miscompilations where
shuffles are getting coalesced as if they were copies.

The CoalescerPair class will replace a lot of the spaghetti logic in JoinCopy
later.

llvm-svn: 105997
2010-06-15 16:04:21 +00:00
Dan Gohman
bab18cae46 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
Dan Gohman
cabaec582f Rename MRegisterInfo to TargetRegisterInfo.
llvm-svn: 46930
2008-02-10 18:45:23 +00:00
Chris Lattner
ad9a6ccb83 Remove attribution from file headers, per discussion on llvmdev.
llvm-svn: 45418
2007-12-29 20:36:04 +00:00
David Greene
2ca4b270db Pluggable coalescers inplementation.
llvm-svn: 41743
2007-09-06 16:18:45 +00:00