@@ -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.
@@ -1347,7 +1343,8 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1347
1343
if (DstReg.isPhysical ()) {
1348
1344
Register NewDstReg = DstReg;
1349
1345
1350
- unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (), DefSubIdx);
1346
+ unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (),
1347
+ DefMI->getOperand (0 ).getSubReg ());
1351
1348
if (NewDstIdx)
1352
1349
NewDstReg = TRI->getSubReg (DstReg, NewDstIdx);
1353
1350
@@ -1496,7 +1493,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1496
1493
MRI->setRegClass (DstReg, NewRC);
1497
1494
1498
1495
// Update machine operands and add flags.
1499
- updateRegDefsUses (DstReg, DstReg, DstIdx, false );
1496
+ updateRegDefsUses (DstReg, DstReg, DstIdx);
1500
1497
NewMI.getOperand (0 ).setSubReg (NewIdx);
1501
1498
// updateRegDefUses can add an "undef" flag to the definition, since
1502
1499
// it will replace DstReg with DstReg.DstIdx. If NewIdx is 0, make
@@ -1816,7 +1813,7 @@ void RegisterCoalescer::addUndefFlag(const LiveInterval &Int, SlotIndex UseIdx,
1816
1813
}
1817
1814
1818
1815
void RegisterCoalescer::updateRegDefsUses (Register SrcReg, Register DstReg,
1819
- unsigned SubIdx, bool IsSubregToReg ) {
1816
+ unsigned SubIdx) {
1820
1817
bool DstIsPhys = DstReg.isPhysical ();
1821
1818
LiveInterval *DstInt = DstIsPhys ? nullptr : &LIS->getInterval (DstReg);
1822
1819
@@ -1856,22 +1853,16 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1856
1853
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr ())
1857
1854
Reads = DstInt->liveAt (LIS->getInstructionIndex (*UseMI));
1858
1855
1859
- bool FullDef = true ;
1860
-
1861
1856
// Replace SrcReg with DstReg in all UseMI operands.
1862
1857
for (unsigned i = 0 , e = Ops.size (); i != e; ++i) {
1863
1858
MachineOperand &MO = UseMI->getOperand (Ops[i]);
1864
1859
1865
1860
// Adjust <undef> flags in case of sub-register joins. We don't want to
1866
1861
// turn a full def into a read-modify-write sub-register def and vice
1867
1862
// versa.
1868
- if (SubIdx && MO.isDef ()) {
1863
+ if (SubIdx && MO.isDef ())
1869
1864
MO.setIsUndef (!Reads);
1870
1865
1871
- if (!Reads)
1872
- FullDef = false ;
1873
- }
1874
-
1875
1866
// A subreg use of a partially undef (super) register may be a complete
1876
1867
// undef use now and then has to be marked that way.
1877
1868
if (MO.isUse () && !DstIsPhys) {
@@ -1903,25 +1894,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1903
1894
MO.substVirtReg (DstReg, SubIdx, *TRI);
1904
1895
}
1905
1896
1906
- if (IsSubregToReg && !FullDef) {
1907
- // If the coalesed instruction doesn't fully define the register, we need
1908
- // to preserve the original super register liveness for SUBREG_TO_REG.
1909
- //
1910
- // We pretended SUBREG_TO_REG was a regular copy for coalescing purposes,
1911
- // but it introduces liveness for other subregisters. Downstream users may
1912
- // have been relying on those bits, so we need to ensure their liveness is
1913
- // captured with a def of other lanes.
1914
-
1915
- // FIXME: Need to add new subrange if tracking subranges. We could also
1916
- // skip adding this if we knew the other lanes are dead, and only for
1917
- // other lanes.
1918
-
1919
- assert (!MRI->shouldTrackSubRegLiveness (DstReg) &&
1920
- " this should update subranges" );
1921
- MachineInstrBuilder MIB (*MF, UseMI);
1922
- MIB.addReg (DstReg, RegState::ImplicitDefine);
1923
- }
1924
-
1925
1897
LLVM_DEBUG ({
1926
1898
dbgs () << " \t\t updated: " ;
1927
1899
if (!UseMI->isDebugInstr ())
@@ -2121,8 +2093,6 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2121
2093
});
2122
2094
}
2123
2095
2124
- const bool IsSubregToReg = CopyMI->isSubregToReg ();
2125
-
2126
2096
ShrinkMask = LaneBitmask::getNone ();
2127
2097
ShrinkMainRange = false ;
2128
2098
@@ -2190,12 +2160,9 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2190
2160
2191
2161
// Rewrite all SrcReg operands to DstReg.
2192
2162
// Also update DstReg operands to include DstIdx if it is set.
2193
- if (CP.getDstIdx ()) {
2194
- assert (!IsSubregToReg && " can this happen?" );
2195
- updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx (), false );
2196
- }
2197
- updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx (),
2198
- IsSubregToReg);
2163
+ if (CP.getDstIdx ())
2164
+ updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx ());
2165
+ updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx ());
2199
2166
2200
2167
// Shrink subregister ranges if necessary.
2201
2168
if (ShrinkMask.any ()) {
0 commit comments