File tree Expand file tree Collapse file tree 2 files changed +387
-0
lines changed Expand file tree Collapse file tree 2 files changed +387
-0
lines changed Original file line number Diff line number Diff line change @@ -1349,6 +1349,8 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
1349
1349
1350
1350
for (MachineBasicBlock *MBB : depth_first (&MF)) {
1351
1351
MachineBasicBlock::iterator I, Next;
1352
+
1353
+ MachineOperand *CurrentKnownM0Val = nullptr ;
1352
1354
for (I = MBB->begin (); I != MBB->end (); I = Next) {
1353
1355
Next = std::next (I);
1354
1356
MachineInstr &MI = *I;
@@ -1361,6 +1363,25 @@ bool SIFoldOperands::runOnMachineFunction(MachineFunction &MF) {
1361
1363
if (IsIEEEMode || (!HasNSZ && !MI.getFlag (MachineInstr::FmNsz)) ||
1362
1364
!tryFoldOMod (MI))
1363
1365
tryFoldClamp (MI);
1366
+
1367
+ // Saw an unknown clobber of m0, so we no longer know what it is.
1368
+ if (CurrentKnownM0Val && MI.modifiesRegister (AMDGPU::M0, TRI))
1369
+ CurrentKnownM0Val = nullptr ;
1370
+ continue ;
1371
+ }
1372
+
1373
+ // Specially track simple redefs of m0 to the same value in a block, so we
1374
+ // can erase the later ones.
1375
+ if (MI.getOperand (0 ).getReg () == AMDGPU::M0) {
1376
+ MachineOperand &NewM0Val = MI.getOperand (1 );
1377
+ if (CurrentKnownM0Val && CurrentKnownM0Val->isIdenticalTo (NewM0Val)) {
1378
+ MI.eraseFromParent ();
1379
+ continue ;
1380
+ }
1381
+
1382
+ // We aren't tracking other physical registers
1383
+ CurrentKnownM0Val = (NewM0Val.isReg () && NewM0Val.getReg ().isPhysical ()) ?
1384
+ nullptr : &NewM0Val;
1364
1385
continue ;
1365
1386
}
1366
1387
You can’t perform that action at this time.
0 commit comments