@@ -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.
@@ -1327,7 +1323,8 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1327
1323
if (DstReg.isPhysical ()) {
1328
1324
Register NewDstReg = DstReg;
1329
1325
1330
- unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (), DefSubIdx);
1326
+ unsigned NewDstIdx = TRI->composeSubRegIndices (CP.getSrcIdx (),
1327
+ DefMI->getOperand (0 ).getSubReg ());
1331
1328
if (NewDstIdx)
1332
1329
NewDstReg = TRI->getSubReg (DstReg, NewDstIdx);
1333
1330
@@ -1471,7 +1468,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1471
1468
MRI->setRegClass (DstReg, NewRC);
1472
1469
1473
1470
// Update machine operands and add flags.
1474
- updateRegDefsUses (DstReg, DstReg, DstIdx, false );
1471
+ updateRegDefsUses (DstReg, DstReg, DstIdx);
1475
1472
NewMI.getOperand (0 ).setSubReg (NewIdx);
1476
1473
// updateRegDefUses can add an "undef" flag to the definition, since
1477
1474
// it will replace DstReg with DstReg.DstIdx. If NewIdx is 0, make
@@ -1786,7 +1783,7 @@ void RegisterCoalescer::addUndefFlag(const LiveInterval &Int, SlotIndex UseIdx,
1786
1783
}
1787
1784
1788
1785
void RegisterCoalescer::updateRegDefsUses (Register SrcReg, Register DstReg,
1789
- unsigned SubIdx, bool IsSubregToReg ) {
1786
+ unsigned SubIdx) {
1790
1787
bool DstIsPhys = DstReg.isPhysical ();
1791
1788
LiveInterval *DstInt = DstIsPhys ? nullptr : &LIS->getInterval (DstReg);
1792
1789
@@ -1826,22 +1823,16 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1826
1823
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr ())
1827
1824
Reads = DstInt->liveAt (LIS->getInstructionIndex (*UseMI));
1828
1825
1829
- bool FullDef = true ;
1830
-
1831
1826
// Replace SrcReg with DstReg in all UseMI operands.
1832
1827
for (unsigned i = 0 , e = Ops.size (); i != e; ++i) {
1833
1828
MachineOperand &MO = UseMI->getOperand (Ops[i]);
1834
1829
1835
1830
// Adjust <undef> flags in case of sub-register joins. We don't want to
1836
1831
// turn a full def into a read-modify-write sub-register def and vice
1837
1832
// versa.
1838
- if (SubIdx && MO.isDef ()) {
1833
+ if (SubIdx && MO.isDef ())
1839
1834
MO.setIsUndef (!Reads);
1840
1835
1841
- if (!Reads)
1842
- FullDef = false ;
1843
- }
1844
-
1845
1836
// A subreg use of a partially undef (super) register may be a complete
1846
1837
// undef use now and then has to be marked that way.
1847
1838
if (MO.isUse () && !DstIsPhys) {
@@ -1873,25 +1864,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
1873
1864
MO.substVirtReg (DstReg, SubIdx, *TRI);
1874
1865
}
1875
1866
1876
- if (IsSubregToReg && !FullDef) {
1877
- // If the coalesed instruction doesn't fully define the register, we need
1878
- // to preserve the original super register liveness for SUBREG_TO_REG.
1879
- //
1880
- // We pretended SUBREG_TO_REG was a regular copy for coalescing purposes,
1881
- // but it introduces liveness for other subregisters. Downstream users may
1882
- // have been relying on those bits, so we need to ensure their liveness is
1883
- // captured with a def of other lanes.
1884
-
1885
- // FIXME: Need to add new subrange if tracking subranges. We could also
1886
- // skip adding this if we knew the other lanes are dead, and only for
1887
- // other lanes.
1888
-
1889
- assert (!MRI->shouldTrackSubRegLiveness (DstReg) &&
1890
- " this should update subranges" );
1891
- MachineInstrBuilder MIB (*MF, UseMI);
1892
- MIB.addReg (DstReg, RegState::ImplicitDefine);
1893
- }
1894
-
1895
1867
LLVM_DEBUG ({
1896
1868
dbgs () << " \t\t updated: " ;
1897
1869
if (!UseMI->isDebugInstr ())
@@ -2091,8 +2063,6 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2091
2063
});
2092
2064
}
2093
2065
2094
- const bool IsSubregToReg = CopyMI->isSubregToReg ();
2095
-
2096
2066
ShrinkMask = LaneBitmask::getNone ();
2097
2067
ShrinkMainRange = false ;
2098
2068
@@ -2160,12 +2130,9 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
2160
2130
2161
2131
// Rewrite all SrcReg operands to DstReg.
2162
2132
// Also update DstReg operands to include DstIdx if it is set.
2163
- if (CP.getDstIdx ()) {
2164
- assert (!IsSubregToReg && " can this happen?" );
2165
- updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx (), false );
2166
- }
2167
- updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx (),
2168
- IsSubregToReg);
2133
+ if (CP.getDstIdx ())
2134
+ updateRegDefsUses (CP.getDstReg (), CP.getDstReg (), CP.getDstIdx ());
2135
+ updateRegDefsUses (CP.getSrcReg (), CP.getDstReg (), CP.getSrcIdx ());
2169
2136
2170
2137
// Shrink subregister ranges if necessary.
2171
2138
if (ShrinkMask.any ()) {
0 commit comments