@@ -381,21 +381,10 @@ void PPCExpandISEL::reorganizeBlockLayout(BlockISELList &BIL,
381
381
MBB->end ());
382
382
NewSuccessor->transferSuccessorsAndUpdatePHIs (MBB);
383
383
384
- // Copy the original liveIns of MBB to NewSuccessor.
385
- for (auto &LI : MBB->liveins ())
386
- NewSuccessor->addLiveIn (LI);
387
-
388
- // After splitting the NewSuccessor block, Regs defined but not killed
389
- // in MBB should be treated as liveins of NewSuccessor.
390
- // Note: Cannot use stepBackward instead since we are using the Reg
391
- // liveness state at the end of MBB (liveOut of MBB) as the liveIn for
392
- // NewSuccessor. Otherwise, will cause cyclic dependence.
393
- LivePhysRegs LPR (*MF->getSubtarget <PPCSubtarget>().getRegisterInfo ());
394
- SmallVector<std::pair<MCPhysReg, const MachineOperand *>, 2 > Clobbers;
395
- for (MachineInstr &MI : *MBB)
396
- LPR.stepForward (MI, Clobbers);
397
- for (auto &LI : LPR)
398
- NewSuccessor->addLiveIn (LI);
384
+ // Update the liveins for NewSuccessor.
385
+ LivePhysRegs LPR;
386
+ computeAndAddLiveIns (LPR, *NewSuccessor);
387
+
399
388
} else {
400
389
// Remove successor from MBB.
401
390
MBB->removeSuccessor (Successor);
@@ -453,32 +442,15 @@ void PPCExpandISEL::populateBlocks(BlockISELList &BIL) {
453
442
bool IsADDIInstRequired = !useSameRegister (Dest, TrueValue);
454
443
bool IsORIInstRequired = !useSameRegister (Dest, FalseValue);
455
444
456
- if (IsADDIInstRequired) {
457
- // Copy the result into the destination if the condition is true.
445
+ // Copy the result into the destination if the condition is true.
446
+ if (IsADDIInstRequired)
458
447
BuildMI (*TrueBlock, TrueBlockI, dl,
459
448
TII->get (isISEL8 (*MI) ? PPC::ADDI8 : PPC::ADDI))
460
449
.add (Dest)
461
450
.add (TrueValue)
462
451
.add (MachineOperand::CreateImm (0 ));
463
452
464
- // Add the LiveIn registers required by true block.
465
- TrueBlock->addLiveIn (TrueValue.getReg ());
466
- }
467
-
468
- if (IsORIInstRequired) {
469
- // Add the LiveIn registers required by false block.
470
- FalseBlock->addLiveIn (FalseValue.getReg ());
471
- }
472
-
473
- if (NewSuccessor) {
474
- // Add the LiveIn registers required by NewSuccessor block.
475
- NewSuccessor->addLiveIn (Dest.getReg ());
476
- NewSuccessor->addLiveIn (TrueValue.getReg ());
477
- NewSuccessor->addLiveIn (FalseValue.getReg ());
478
- NewSuccessor->addLiveIn (ConditionRegister.getReg ());
479
- }
480
-
481
- // Copy the value into the destination if the condition is false.
453
+ // Copy the result into the destination if the condition is false.
482
454
if (IsORIInstRequired)
483
455
BuildMI (*FalseBlock, FalseBlockI, dl,
484
456
TII->get (isISEL8 (*MI) ? PPC::ORI8 : PPC::ORI))
@@ -490,6 +462,18 @@ void PPCExpandISEL::populateBlocks(BlockISELList &BIL) {
490
462
491
463
NumExpanded++;
492
464
}
465
+
466
+ if (IsTrueBlockRequired) {
467
+ // Update the liveins for TrueBlock.
468
+ LivePhysRegs LPR;
469
+ computeAndAddLiveIns (LPR, *TrueBlock);
470
+ }
471
+
472
+ if (IsFalseBlockRequired) {
473
+ // Update the liveins for FalseBlock.
474
+ LivePhysRegs LPR;
475
+ computeAndAddLiveIns (LPR, *FalseBlock);
476
+ }
493
477
}
494
478
495
479
void PPCExpandISEL::expandMergeableISELs (BlockISELList &BIL) {
0 commit comments