@@ -1374,27 +1374,6 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1374
1374
MachineInstr &NewMI = *std::prev (MII);
1375
1375
NewMI.setDebugLoc (DL);
1376
1376
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
-
1398
1377
// In a situation like the following:
1399
1378
// %0:subreg = instr ; DefMI, subreg = DstIdx
1400
1379
// %1 = copy %0:subreg ; CopyMI, SrcIdx = 0
@@ -1523,6 +1502,26 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
1523
1502
// sure that "undef" is not set.
1524
1503
if (NewIdx == 0 )
1525
1504
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
+
1526
1525
// Add dead subregister definitions if we are defining the whole register
1527
1526
// but only part of it is live.
1528
1527
// This could happen if the rematerialization instruction is rematerializing
0 commit comments