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