@@ -1374,27 +1374,6 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
13741374 MachineInstr &NewMI = *std::prev (MII);
13751375 NewMI.setDebugLoc (DL);
13761376
1377- // In a situation like the following:
1378- //
1379- // undef %2.subreg:reg = INST %1:reg ; DefMI (rematerializable),
1380- // ; DefSubIdx = subreg
1381- // %3:reg = COPY %2 ; SrcIdx = DstIdx = 0
1382- // .... = SOMEINSTR %3:reg
1383- //
1384- // there are no subranges for %3 so after rematerialization we need
1385- // to explicitly create them. Undefined subranges are removed later on.
1386- if (DstReg.isVirtual () && DefSubIdx && !CP.getSrcIdx () && !CP.getDstIdx () &&
1387- MRI->shouldTrackSubRegLiveness (DstReg)) {
1388- LiveInterval &DstInt = LIS->getInterval (DstReg);
1389- if (!DstInt.hasSubRanges ()) {
1390- LaneBitmask FullMask = MRI->getMaxLaneMaskForVReg (DstReg);
1391- LaneBitmask UsedLanes = TRI->getSubRegIndexLaneMask (DefSubIdx);
1392- LaneBitmask UnusedLanes = FullMask & ~UsedLanes;
1393- DstInt.createSubRangeFrom (LIS->getVNInfoAllocator (), UsedLanes, DstInt);
1394- DstInt.createSubRangeFrom (LIS->getVNInfoAllocator (), UnusedLanes, DstInt);
1395- }
1396- }
1397-
13981377 // In a situation like the following:
13991378 // %0:subreg = instr ; DefMI, subreg = DstIdx
14001379 // %1 = copy %0:subreg ; CopyMI, SrcIdx = 0
@@ -1523,6 +1502,26 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
15231502 // sure that "undef" is not set.
15241503 if (NewIdx == 0 )
15251504 NewMI.getOperand (0 ).setIsUndef (false );
1505+
1506+ // In a situation like the following:
1507+ //
1508+ // undef %2.subreg:reg = INST %1:reg ; DefMI (rematerializable),
1509+ // ; DefSubIdx = subreg
1510+ // %3:reg = COPY %2 ; SrcIdx = DstIdx = 0
1511+ // .... = SOMEINSTR %3:reg
1512+ //
1513+ // there are no subranges for %3 so after rematerialization we need
1514+ // to explicitly create them. Undefined subranges are removed later on.
1515+ if (DefSubIdx && !CP.getSrcIdx () && !CP.getDstIdx () &&
1516+ MRI->shouldTrackSubRegLiveness (DstReg) && !DstInt.hasSubRanges ()) {
1517+ LaneBitmask FullMask = MRI->getMaxLaneMaskForVReg (DstReg);
1518+ LaneBitmask UsedLanes = TRI->getSubRegIndexLaneMask (DefSubIdx);
1519+ LaneBitmask UnusedLanes = FullMask & ~UsedLanes;
1520+ VNInfo::Allocator &Alloc = LIS->getVNInfoAllocator ();
1521+ DstInt.createSubRangeFrom (Alloc, UsedLanes, DstInt);
1522+ DstInt.createSubRangeFrom (Alloc, UnusedLanes, DstInt);
1523+ }
1524+
15261525 // Add dead subregister definitions if we are defining the whole register
15271526 // but only part of it is live.
15281527 // This could happen if the rematerialization instruction is rematerializing
0 commit comments