@@ -305,11 +305,7 @@ namespace {
305
305
// / number if it is not zero. If DstReg is a physical register and the
306
306
// / existing subregister number of the def / use being updated is not zero,
307
307
// / make sure to set it to the correct physical subregister.
308
- // /
309
- // / If \p IsSubregToReg, we are coalescing a DstReg = SUBREG_TO_REG
310
- // / SrcReg. This introduces an implicit-def of DstReg on coalesced users.
311
- void updateRegDefsUses (Register SrcReg, Register DstReg, unsigned SubIdx,
312
- bool IsSubregToReg);
308
+ void updateRegDefsUses (Register SrcReg, Register DstReg, unsigned SubIdx);
313
309
314
310
// / If the given machine operand reads only undefined lanes add an undef
315
311
// / flag.
@@ -1332,7 +1328,8 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1332
1328
if (DstReg.isPhysical ()) {
1333
1329
Register NewDstReg = DstReg;
1334
1330
1335
- unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (), DefSubIdx);
1331
+ unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (),
1332
+ DefMI->getOperand (0 ).getSubReg ());
1336
1333
if (NewDstIdx)
1337
1334
NewDstReg = TRI->getSubReg (DstReg, NewDstIdx);
1338
1335
@@ -1481,7 +1478,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1481
1478
MRI->setRegClass (DstReg, NewRC);
1482
1479
1483
1480
// Update machine operands and add flags.
1484
- updateRegDefsUses (DstReg, DstReg, DstIdx, false );
1481
+ updateRegDefsUses (DstReg, DstReg, DstIdx);
1485
1482
NewMI.getOperand (0 ).setSubReg (NewIdx);
1486
1483
// updateRegDefUses can add an "undef" flag to the definition, since
1487
1484
// it will replace DstReg with DstReg.DstIdx. If NewIdx is 0, make
@@ -1803,7 +1800,7 @@ void RegisterCoalescer::addUndefFlag(const LiveInterval &Int, SlotIndex UseIdx,
1803
1800
}
1804
1801
1805
1802
void RegisterCoalescer::updateRegDefsUses (Register SrcReg, Register DstReg,
1806
- unsigned SubIdx, bool IsSubregToReg ) {
1803
+ unsigned SubIdx) {
1807
1804
bool DstIsPhys = DstReg.isPhysical ();
1808
1805
LiveInterval *DstInt = DstIsPhys ? nullptr : &LIS->getInterval (DstReg);
1809
1806
@@ -1843,22 +1840,16 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1843
1840
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr ())
1844
1841
Reads = DstInt->liveAt (LIS->getInstructionIndex (*UseMI));
1845
1842
1846
- bool FullDef = true ;
1847
-
1848
1843
// Replace SrcReg with DstReg in all UseMI operands.
1849
1844
for (unsigned i = 0 , e = Ops.size (); i != e; ++i) {
1850
1845
MachineOperand &MO = UseMI->getOperand (Ops[i]);
1851
1846
1852
1847
// Adjust <undef> flags in case of sub-register joins. We don't want to
1853
1848
// turn a full def into a read-modify-write sub-register def and vice
1854
1849
// versa.
1855
- if (SubIdx && MO.isDef ()) {
1850
+ if (SubIdx && MO.isDef ())
1856
1851
MO.setIsUndef (!Reads);
1857
1852
1858
- if (!Reads)
1859
- FullDef = false ;
1860
- }
1861
-
1862
1853
// A subreg use of a partially undef (super) register may be a complete
1863
1854
// undef use now and then has to be marked that way.
1864
1855
if (MO.isUse () && !DstIsPhys) {
@@ -1890,25 +1881,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1890
1881
MO.substVirtReg (DstReg, SubIdx, *TRI);
1891
1882
}
1892
1883
1893
- if (IsSubregToReg && !FullDef) {
1894
- // If the coalesed instruction doesn't fully define the register, we need
1895
- // to preserve the original super register liveness for SUBREG_TO_REG.
1896
- //
1897
- // We pretended SUBREG_TO_REG was a regular copy for coalescing purposes,
1898
- // but it introduces liveness for other subregisters. Downstream users may
1899
- // have been relying on those bits, so we need to ensure their liveness is
1900
- // captured with a def of other lanes.
1901
-
1902
- // FIXME: Need to add new subrange if tracking subranges. We could also
1903
- // skip adding this if we knew the other lanes are dead, and only for
1904
- // other lanes.
1905
-
1906
- assert (!MRI->shouldTrackSubRegLiveness (DstReg) &&
1907
- " this should update subranges" );
1908
- MachineInstrBuilder MIB (*MF, UseMI);
1909
- MIB.addReg (DstReg, RegState::ImplicitDefine);
1910
- }
1911
-
1912
1884
LLVM_DEBUG ({
1913
1885
dbgs () << " \t\t updated: " ;
1914
1886
if (!UseMI->isDebugInstr ())
@@ -2108,8 +2080,6 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2108
2080
});
2109
2081
}
2110
2082
2111
- const bool IsSubregToReg = CopyMI->isSubregToReg ();
2112
-
2113
2083
ShrinkMask = LaneBitmask::getNone ();
2114
2084
ShrinkMainRange = false ;
2115
2085
@@ -2177,12 +2147,9 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2177
2147
2178
2148
// Rewrite all SrcReg operands to DstReg.
2179
2149
// Also update DstReg operands to include DstIdx if it is set.
2180
- if (CP.getDstIdx ()) {
2181
- assert (!IsSubregToReg && " can this happen?" );
2182
- updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx (), false );
2183
- }
2184
- updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx (),
2185
- IsSubregToReg);
2150
+ if (CP.getDstIdx ())
2151
+ updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx ());
2152
+ updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx ());
2186
2153
2187
2154
// Shrink subregister ranges if necessary.
2188
2155
if (ShrinkMask.any ()) {
0 commit comments